Skip to content

Commit f647bb6

Browse files
authored
Create DigitalClock.py
Digital Clock using tkinter
1 parent 9629aef commit f647bb6

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

DigitalClock.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# importing whole module
2+
from tkinter import *
3+
from tkinter.ttk import *
4+
5+
# importing strftime function to
6+
# retrieve system's time
7+
from time import strftime
8+
9+
# creating tkinter window
10+
root = Tk()
11+
root.title('Clock')
12+
13+
# This function is used to
14+
# display time on the label
15+
def time():
16+
string = strftime('%H:%M:%S %p')
17+
lbl.config(text = string)
18+
lbl.after(1000, time)
19+
20+
# Styling the label widget so that clock
21+
# will look more attractive
22+
lbl = Label(root, font = ('calibri', 40, 'bold'),
23+
background = 'purple',
24+
foreground = 'white')
25+
26+
# Placing clock at the centre
27+
# of the tkinter window
28+
lbl.pack(anchor = 'center')
29+
time()
30+
31+
mainloop()

0 commit comments

Comments
 (0)