-
-
Notifications
You must be signed in to change notification settings - Fork 360
Update DigitalClock.py #477
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,28 @@ | ||
import tkinter | ||
import tkinter as tk | ||
from time import strftime | ||
|
||
top = tkinter.Tk() | ||
top.title('Digital Clock') | ||
# 0,0 makes the window non-resizable | ||
top.resizable(0,0) | ||
# Create main window | ||
top = tk.Tk() | ||
top.title('🕒 Digital Clock') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] Using emojis in window titles may cause display issues on some operating systems or environments that don't support Unicode properly. Consider using plain text for better compatibility.
Suggested change
top.title('🕒 Digital Clock')
top.title('Digital Clock')
Copilot uses AI. Check for mistakes. |
||
top.geometry('500x150') | ||
top.resizable(0, 0) | ||
top.configure(bg='#1e1e2f') # Dark background | ||
|
||
# Function to update time | ||
def time(): | ||
# %p defines AM or PM | ||
string = strftime('%H: %M: %S %p') | ||
clockTime.config(text=string) | ||
clockTime.after(1000, time) | ||
string = strftime('%I:%M:%S %p') # 12-hour format with AM/PM | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment mentions 'AM/PM' but the format string '%I:%M:%S %p' will display AM/PM at the end. However, the original code used '%H: %M: %S %p' which mixed 24-hour format (%H) with AM/PM (%p), which doesn't make sense. The new format is correct, but the original logic suggests 24-hour format was intended. Copilot uses AI. Check for mistakes. |
||
clock_label.config(text=string) | ||
clock_label.after(1000, time) | ||
|
||
clockTime = tkinter.Label(top, font=('courier new', 40), | ||
background='red',foreground='black') | ||
clockTime.pack(anchor='center') | ||
# Digital clock label styling | ||
clock_label = tk.Label(top, font=('Segoe UI', 48, 'bold'), | ||
background='#1e1e2f', | ||
foreground='#00FFCC', | ||
padx=20, pady=20) | ||
clock_label.pack(anchor='center', expand=True) | ||
|
||
# Start clock | ||
time() | ||
top.mainloop() | ||
|
||
# Start the main loop | ||
top.mainloop() |