Bitcoin Forum
November 09, 2024, 10:14:03 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [Windows] Ticker in background image  (Read 916 times)
alkhdaniel (OP)
Member
**
Offline Offline

Activity: 114
Merit: 10


View Profile
November 09, 2013, 04:17:24 PM
 #1

Puts a simple ticker showing last price at mtgox/btcchina/bitstamp/btce on the bottom left of your wallpaper. - image

Updates every 45 seconds.

Download

How to: replace background.jpg with whatever background image you wish to use (you can use other extensions too, just rename it to .jpg and it'll probably work even if it's not really a .jpg). Won't work correctly if image is smaller than screen resolution.
How to stop? Kill background.exe in task manager.


Source, python, requires PIL & optionally singleton.py

Code:
# -*- coding: cp1252 -*-
import PIL, urllib, json, ctypes, time, singleton
from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw
from ctypes import windll, wintypes, byref

me = singleton.SingleInstance() #checks if process is already running, remove to skip singleton dependency.

work_area = wintypes.RECT()
if (windll.user32.SystemParametersInfoA(48, 0, byref(work_area), 0)):
    height=work_area.bottom
width = windll.user32.GetSystemMetrics(0)

while True:
    mtgox = urllib.urlopen('http://data.mtgox.com/api/1/BTCUSD/ticker_fast')
    mtgox = json.load(mtgox)
    mtgox = format(float(mtgox["return"]["last_local"]["display"].replace("$", "")), '.2f')
    btce = urllib.urlopen('https://btc-e.com/api/2/btc_usd/ticker')
    btce = json.load(btce)
    btce = format(float(btce["ticker"]["last"]), '.2f')
    bits = urllib.urlopen('https://www.bitstamp.net/api/ticker/')
    bits = json.load(bits)
    bits = format(float(bits["last"]), '.2f')
    btcc = json.load(urllib.urlopen('https://data.btcchina.com/data/ticker'))
    btcc = format(float(btcc["ticker"]["last"]), '.1f')

    font = ImageFont.truetype("lucon.ttf",18)
    img=Image.open("background.jpg")
    draw = ImageDraw.Draw(img)
    draw.text((width-144-11*0, height-18*1-2),"MTGOX $" + str(mtgox),(255,255,255),font=font)
    draw.text((width-144-11*0, height-18*2-2),"BTC-E $" + str(btce),(255,255,255),font=font)
    draw.text((width-144-11*3, height-18*3-2),"BITSTAMP $" + str(bits),(255,255,255),font=font)
    draw.text((width-144-11*3, height-18*4-2),"BTCCHINA ¥" + str(btcc),(255,255,255),font=font)

    draw = ImageDraw.Draw(img)
    img.save("bg.bmp")

    ctypes.windll.user32.SystemParametersInfoA(20, 0, "bg" , 0x1)
    print "update"
    time.sleep(45)

Useful? Send a thanks - 1Ne2FZThx2ZCzPGjQw7ePRuCWrBMGNHGVB
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!