-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpython.py
39 lines (31 loc) · 1.05 KB
/
python.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import requests
import json
import time
import os
import tkinter as tk
url_btc = 'https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT'
url_arpa = 'https://api.binance.com/api/v3/ticker/price?symbol=ARPAUSDT'
def update_prices():
try:
response_btc = requests.get(url_btc)
data_btc = json.loads(response_btc.text)
price_btc = float(data_btc['price'])
response_arpa = requests.get(url_arpa)
data_arpa = json.loads(response_arpa.text)
price_arpa = float(data_arpa['price'])
os.system("clear")
btc_label.config(text=f'BTCUSDT: {price_btc:.2f}')
arpa_label.config(text=f'ARPAUSDT: {price_arpa:.8f}')
except:
os.system("clear")
btc_label.config(text="BTCUSDT: ...")
arpa_label.config(text="ARPAUSDT: ...")
root.after(1000, update_prices)
root = tk.Tk()
root.title("Crypto Prices")
btc_label = tk.Label(root, font=("Arial", 20))
btc_label.pack(pady=10)
arpa_label = tk.Label(root, font=("Arial", 20))
arpa_label.pack(pady=10)
update_prices()
root.mainloop()