Python Digital Clock with GUI (Tkinter)

Python Digital Clock with GUI (Tkinter)

🕒 Python Digital Clock with GUI

Level: Beginner
Tech used: Python, Tkinter, Time

🔧 What You’ll Build

A real-time digital clock using Python’s Tkinter GUI library. It updates every second and is great practice for using loops and GUI labels.

🧰 Requirements

  • Python 3.x
  • tkinter (built-in)

💻 Sample Python Code


import tkinter as tk
from time import strftime

def update_time():
    current = strftime('%H:%M:%S')
    label.config(text=current)
    label.after(1000, update_time)

root = tk.Tk()
root.title("Digital Clock")

label = tk.Label(root, font=('calibri', 40, 'bold'), background='black', foreground='lime')
label.pack(anchor='center')

update_time()
root.mainloop()
  

🎯 Key Concepts

  • Using strftime from the time module
  • GUI label updates with .after()
  • Real-time loops in Tkinter

📎 Extra Resources

Useful Tools:
🛍️ Top Wall Clocks on Amazon

Comments