Skip to content

Instantly share code, notes, and snippets.

@harendra21
Created May 10, 2022 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harendra21/bf1dd855fbfd7e2628186e815db1e03d to your computer and use it in GitHub Desktop.
Save harendra21/bf1dd855fbfd7e2628186e815db1e03d to your computer and use it in GitHub Desktop.
import tkinter as tk
from tkinter import ttk
import urllib.request
import json
import time
def get_luno():
# to change ticker pair, look at here https://api.mybitx.com/api/1/tickers
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"])
bLable.configure(text="Time: " +
str(time.strftime("%Y-%m-%d %H:%M:%S",
time.gmtime(get_luno()["timestamp"]/1000 + 28800))))
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)
bLable = ttk.Label(text="Time: " +
str(time.strftime("%Y-%m-%d %H:%M:%S",
time.gmtime(get_luno()["timestamp"]/1000 + 28800))))
bLable.grid(column=0, row=1, padx=8, pady=4)
action = ttk.Button(win, text="Refresh", command=refresh_price)
action.grid(column=0, row=2, padx=8, pady=4)
win.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment