π» Live Crypto Price Tracker using Python GUI (tkinter + API) – FuzzuTech
Demo :
Click Video πππ
⭐ Features:
-
π₯ App: Real-time Crypto Price Checker
-
π» Stack: Python, tkinter, requests, threading
-
⚙️ Functions: Auto-refresh, API Fetch, Threaded UI
-
π₯ Video Embed: [YouTube Short URL here]
-
π Tags: crypto, gui, python, hackingstyle, coderlife
Code :
import tkinter as tk
from tkinter import ttk
import requests
import threading
# ---- Function to fetch crypto price ----
def get_crypto_price(symbol):
url = f"https://api.coingecko.com/api/v3/simple/price?ids={symbol}&vs_currencies=usd"
try:
data = requests.get(url).json()
return data.get(symbol, {}).get("usd", "N/A")
except Exception:
return "Error"
# ---- Function to update price in UI ----
def update_price():
symbol = symbol_var.get().lower()
price = get_crypto_price(symbol)
result_var.set(f"${price}")
root.after(5000, update_price) # Auto-refresh every 5 sec
# ---- Function to run fetch in a thread ----
def start_tracking():
result_var.set("Loading...")
threading.Thread(target=update_price).start()
# ---- UI Design ----
root = tk.Tk()
root.title("πΈ Fuzzu Crypto Price Tracker")
root.geometry("450x300")
root.configure(bg="#121212")
# ---- Style ----
style = ttk.Style()
style.theme_use("clam")
style.configure("TLabel", foreground="white", background="#121212", font=("Segoe UI", 12))
style.configure("TButton", foreground="#ffffff", background="#4caf50", font=("Segoe UI", 11), padding=6)
style.map("TButton", background=[("active", "#66bb6a")])
style.configure("TEntry", padding=5)
# ---- Variables ----
symbol_var = tk.StringVar(value="bitcoin")
result_var = tk.StringVar(value="")
# ---- Widgets ----
ttk.Label(root, text="Enter Crypto Symbol (e.g. bitcoin, ethereum):").pack(pady=(20, 10))
ttk.Entry(root, textvariable=symbol_var, width=30, font=("Segoe UI", 11)).pack()
ttk.Button(root, text="π Start Tracking", command=start_tracking).pack(pady=15)
ttk.Label(root, text="Current Price:", font=("Segoe UI", 12)).pack(pady=10)
ttk.Label(root, textvariable=result_var, font=("Segoe UI", 20, "bold"), foreground="#00e676", background="#121212").pack()
# ---- Start App ----
root.mainloop()
Comments
Post a Comment