Skip to content

Commit 5a45330

Browse files
Merge pull request souravjain540#119 from MeenakshyBS/patch-5
Create DigitalClock.py
2 parents 1623ffd + f647bb6 commit 5a45330

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

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)