-
-
Couldn't load subscription status.
- Fork 381
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
base: main
Are you sure you want to change the base?
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') | ||
| 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 | ||
|
||
| 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() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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.