-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdigital_clock.py
More file actions
30 lines (27 loc) · 1004 Bytes
/
Copy pathdigital_clock.py
File metadata and controls
30 lines (27 loc) · 1004 Bytes
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
"""
╔═════════════════════════════════════════╗
║ 🕛 DIGITAL CLOCK ║
╚═════════════════════════════════════════╝
A simple Python GUI application built with Tkinter that displays
the current day, date, and time in a digital clock format.
"""
import time
import tkinter as tk
root = tk.Tk()
root.title("Digital Clock")
def current_time():
# current time in hours, minutes and seconds and displays on the clock
time_string = time.strftime("%A, %b %d \n\n %I:%M:%S %p")
clock_label.config(text=time_string)
# update the time in every 1000 ms
clock_label.after(1000, current_time)
clock_label = tk.Label(
root,
text="Digital Clock",
font=("Arial", 24),
background="black",
foreground="pale green"
)
clock_label.pack(anchor="center")
current_time()
root.mainloop()