Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Digital Clock Project. #25

Merged
merged 6 commits into from
Dec 23, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions Digital_Clock/digital_clock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

import tkinter as tk
import time
from tkinter.font import Font

'''
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).
'''
DarkSlayer102 marked this conversation as resolved.
Show resolved Hide resolved


def clocks():
'''
This function displays the current time.
'''
currentTime = time.gmtime()
currentTime = f'{currentTime.tm_hour}:{currentTime.tm_min}:{currentTime.tm_sec}'
clock.config(text=currentTime)
clock.after(200, clocks)
'''
This is simply printing out to verify whether it is functioning correctly or not.
'''
print("Working Properly")
DarkSlayer102 marked this conversation as resolved.
Show resolved Hide resolved


'''
Here I created a instance of TK class
'''
window = Tk()
# creating a title
window.title("Digital Clock")
# creating background color
window.config(bg="black")

font1 = Font(family="Arial", size=90, weight="normal")
# creating a header using Label Widget
header = Label(window, text="Time Clock", font=font1, bg="gray", fg="white")
# using grid() to place the header somewhere comfortable in the gui
header.grid(row=1, column=2)
'''
A clock is being constructed using the Label Widget, which exhibits the current time and is positioned using grid.
'''
clock = Label(window, font=("times", 90, "bold"), bg="blue", fg='white')
clock.grid(row=2, column=2, padx=620, pady=250)

'''

calling the function here
'''
clocks()
DarkSlayer102 marked this conversation as resolved.
Show resolved Hide resolved

'''
running the main window
'''
DarkSlayer102 marked this conversation as resolved.
Show resolved Hide resolved
if __name__ == "__main__":

window.mainloop()
DarkSlayer102 marked this conversation as resolved.
Show resolved Hide resolved