Skip to content

Commit cd7106a

Browse files
Merge pull request #1691 from sagnik-p/simple-clock-gui
added clock.py
2 parents 7b3f102 + c74fbd8 commit cd7106a

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-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

Simple-Clock-Gui/readme.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SIMPLE GUI CLOCK
2+
3+
This python script displays the current time in a GUI format
4+
5+
These can be customized
6+
1. The format of time display (like HH:MM:SS)
7+
2. The background and foreground colour
8+
3. The refresh rate / update frequency

0 commit comments

Comments
 (0)