-
Notifications
You must be signed in to change notification settings - Fork 632
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #292 from Tark-pea/patch-2
Documentation added to clock.py
- Loading branch information
Showing
1 changed file
with
18 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |