-
Notifications
You must be signed in to change notification settings - Fork 32
/
BitcoinTracker.py
45 lines (30 loc) · 936 Bytes
/
BitcoinTracker.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
39
40
41
42
43
# -*- coding: utf-8 -*-
"""
Created on Fri Mar 24 03:48:25 2023
@author: Aishwarya
"""
import requests
import tkinter as tk
from datetime import datetime
def trackBitcoin():
url = "https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=USD,JPY,EUR"
response = requests.get(url).json()
price = response["USD"]
time = datetime.now().strftime("%H:%M:%S")
labelPrice.config(text = str(price) + "$")
labelTime.config(text = "Updated at: " + time)
canvas.after(500,trackBitcoin)
canvas = tk.Tk()
canvas.geometry("400x500")
canvas.title("Bitcoin Tracker")
f1 = ("poppins", 24, "bold")
f2 = ("poppins", 22, "bold")
f3 = ("poppins", 18, "normal")
label = tk.Label(canvas, text= "Bitcoin Price", font = f1)
label.pack(pady=20)
labelPrice = tk.Label(canvas, font=f2)
labelPrice.pack(pady=20)
labelTime = tk.Label(canvas, font=f3)
labelTime.pack(pady=20)
trackBitcoin()
canvas.mainloop()