-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdigitalclock.py
More file actions
41 lines (36 loc) · 1.11 KB
/
digitalclock.py
File metadata and controls
41 lines (36 loc) · 1.11 KB
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
import tkinter
import tkinter as tk
from time import strftime
top = tkinter.Tk()
top.title('Digital Clock')
# 0,0 makes the window non-resizable
top.resizable(0,0)
# Create main window
top = tk.Tk()
top.title('🕒 Digital Clock')
top.geometry('500x150')
top.resizable(0, 0)
top.configure(bg='#1e1e2f') # Dark background
# Function to update time
def time():
# %p defines AM or PM
string = strftime('%H: %M: %S %p')
clockTime.config(text=string)
clockTime.after(1000, time)
string = strftime('%I:%M:%S %p') # 12-hour format with AM/PM
clock_label.config(text=string)
clock_label.after(1000, time)
clockTime = tkinter.Label(top, font=('courier new', 40),
background='red',foreground='black')
clockTime.pack(anchor='center')
# Digital clock label styling
clock_label = tk.Label(top, font=('Segoe UI', 48, 'bold'),
background='#1e1e2f',
foreground='#00FFCC',
padx=20, pady=20)
clock_label.pack(anchor='center', expand=True)
# Start clock
time()
top.mainloop()
# Start the main loop
top.mainloop()