Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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