Created
July 25, 2017 16:06
-
-
Save amirulabu/7555f19a7f83458840223a7246699604 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tkinter as tk | |
from tkinter import ttk | |
import urllib.request | |
import json | |
import schedule, time | |
def get_luno(): | |
req = urllib.request.urlopen("https://api.mybitx.com/api/1/ticker?pair=XBTMYR") | |
x = json.loads(req.read().decode("utf-8")) | |
req.close() | |
return x | |
def refresh_price(): | |
aLable.configure(text="Ask price: RM " + get_luno()["ask"]) | |
#print(get_luno()["ask"]) | |
win = tk.Tk() | |
win.title("Bitcoin price in MYR") | |
aLable = ttk.Label(win, text="Ask price: RM " + get_luno()["ask"]) | |
aLable.grid(column=0, row=0, padx=8, pady=4) | |
action = ttk.Button(win, text="Refresh", command=refresh_price) | |
action.grid(column=0, row=1, padx=8, pady=4) | |
#schedule.every(1).minutes.do(refresh_price) | |
win.mainloop() | |
#while True: | |
# schedule.run_pending() | |
# time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment