-
Notifications
You must be signed in to change notification settings - Fork 3
/
digitalclock.py
59 lines (45 loc) · 1.63 KB
/
digitalclock.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import tkinter as tk
from time import strftime
def light_theme():
frame = tk.Frame(root, bg="#93D1B0")
frame.place(relx=0.1, rely=0.1, relwidth=0.8, relheight=0.8)
lbl_1 = tk.Label(frame, font=('Times New Roman', 50, 'bold'),
background='#93D1B0', foreground='#fff')
lbl_1.pack(anchor="s")
def time():
string = strftime('%I:%M:%S %p')
lbl_1.config(text=string)
lbl_1.after(1000, time)
time()
def dark_theme():
frame = tk.Frame(root, bg="#22478a")
frame.place(relx=0.1, rely=0.1, relwidth=0.8, relheight=0.8)
lbl_2 = tk.Label(frame, font=('Times New Roman', 50, 'bold'),
background='#22478a', foreground='#000')
lbl_2.pack(anchor="s")
def time():
string = strftime('%I:%M:%S %p')
lbl_2.config(text=string)
lbl_2.after(1000, time)
time()
root = tk.Tk()
root.title("Digital Clock")
canvas = tk.Canvas(root, height=120, width=500)
canvas.pack()
frame = tk.Frame(root, bg='#93D1B0')
frame.place(relx=0.1, rely=0.1, relwidth=0.8, relheight=0.8)
lbl = tk.Label(frame, font=('Times New Roman', 50, 'bold'),
background='#93D1B0', foreground='#fff')
lbl.pack(anchor="s")
def time():
string = strftime('%I:%M:%S %p')
lbl.config(text=string)
lbl.after(1000, time)
time()
menubar = tk.Menu(root)
theme_menu = tk.Menu(menubar, tearoff=0)
theme_menu.add_command(label="Light", command=light_theme)
theme_menu.add_command(label="Dark", command=dark_theme)
menubar.add_cascade(label="Theme", menu=theme_menu)
root.config(menu=menubar)
root.mainloop()