Skip to content

Commit 181b0de

Browse files
committed
added clock.py
1 parent cbe16aa commit 181b0de

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Simple-Clock-Gui/clock.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from tkinter import * # import everything from tkinter module
2+
from time import strftime # import strftime from time module for getting the time
3+
4+
root = Tk() # create a GUI with tkinter
5+
root.title('Clock_Python') # title of the window
6+
lbl = Label(root, font = ('callibri', 45, 'bold'), #specify the font, font size, and others like bold,italics,underlined,etc..
7+
background = 'black', # background color
8+
foreground = 'white') # foreground color
9+
10+
def time(): # call this function to display the time
11+
string = strftime('%H:%M:%S %p') # specify the format of the time
12+
lbl.config(text = string) # get the time in the specified format
13+
lbl.after(1000, time)
14+
15+
16+
lbl.pack(anchor = 'center') # centre align the text
17+
time() # show the time
18+
19+
mainloop() # loop the program
20+
21+
# now you can make it a standalone desktop app (.exe) with pyinstaller or auto-py-to-exe

0 commit comments

Comments
 (0)