Skip to content

Commit 6ef7a72

Browse files
committed
I have included my Digital_Clock into the Python-Projects folder
1 parent 140553a commit 6ef7a72

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

Digital_Clock/digital_clock.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
from tkinter import *
3+
import time
4+
from tkinter.font import Font
5+
6+
'''
7+
In this project, I have imported all the necessary packages, including time and Tkinter. Tkinter is a built-in library that enables the creation of Graphical User Interfaces (GUIs).
8+
'''
9+
10+
11+
def clocks():
12+
'''
13+
This function displays the current time.
14+
'''
15+
currentTime = time.gmtime()
16+
currentTime = f'{currentTime.tm_hour}:{currentTime.tm_min}:{currentTime.tm_sec}'
17+
clock.config(text=currentTime)
18+
clock.after(200, clocks)
19+
'''
20+
This is simply printing out to verify whether it is functioning correctly or not.
21+
'''
22+
print("Working Properly")
23+
24+
25+
'''
26+
Here I created a instance of TK class
27+
'''
28+
window = Tk()
29+
# creating a title
30+
window.title("Digital Clock")
31+
# creating background color
32+
window.config(bg="black")
33+
34+
font1 = Font(family="Arial", size=90, weight="normal")
35+
# creating a header using Label Widget
36+
header = Label(window, text="Time Clock", font=font1, bg="gray", fg="white")
37+
# using grid() to place the header somewhere comfortable in the gui
38+
header.grid(row=1, column=2)
39+
'''
40+
A clock is being constructed using the Label Widget, which exhibits the current time and is positioned using grid.
41+
'''
42+
clock = Label(window, font=("times", 90, "bold"), bg="blue", fg='white')
43+
clock.grid(row=2, column=2, padx=620, pady=250)
44+
45+
'''
46+
47+
calling the function here
48+
'''
49+
clocks()
50+
51+
'''
52+
running the main window
53+
'''
54+
if __name__ == "__main__":
55+
56+
window.mainloop()

0 commit comments

Comments
 (0)