Skip to content

Commit

Permalink
Merge pull request #292 from Tark-pea/patch-2
Browse files Browse the repository at this point in the history
Documentation added to clock.py
  • Loading branch information
Mrinank-Bhowmick authored Jul 24, 2023
2 parents 1d585ae + 6407be1 commit 02e5c75
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions projects/Alarm Clock/clock.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
# Importing the necessary modules
import tkinter
from time import strftime

# Creating the main application window
top = tkinter.Tk()
top.title("Clock")
top.resizable(0, 0)

top.title("Clock") # Setting the title of the window
top.resizable(0, 0) # Making the window non-resizable

# Function to update the time display
def time():
# Get the current time in the format HH:MM:SS AM/PM
string = strftime("%H:%M:%S %p")

# Update the text of the clockTime Label with the current time
clockTime.config(text=string)
clockTime.after(1000, time)

# Schedule the time function to be called again after 1000 milliseconds (1 second)
clockTime.after(1000, time)

# Creating a Label widget to display the time
clockTime = tkinter.Label(
top,
font=(
"courier new",
40,
),
font=("courier new", 40),
background="black",
foreground="white",
)

# Position the Label widget in the center of the window
clockTime.pack(anchor="center")

# Call the time function to start updating the time display
time()

# Start the Tkinter main event loop
top.mainloop()

0 comments on commit 02e5c75

Please sign in to comment.