forked from OpenBMB/ChatDev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
30 lines (30 loc) · 1.02 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
'''
This is the main file for the digital clock application.
It initializes the GUI and starts the clock.
'''
import tkinter as tk
from datetime import datetime
class DigitalClockApp:
def __init__(self, root):
"""
Initializes the DigitalClockApp class.
Args:
root (tkinter.Tk): The root window of the application.
"""
self.root = root
self.root.title("Digital Clock")
self.time_label = tk.Label(root, font=("Arial", 80), bg="black", fg="white")
self.time_label.pack(padx=50, pady=50)
self.update_clock()
def update_clock(self):
"""
Updates the clock label with the current time.
This method is called every second to update the clock label with the current time.
"""
current_time = datetime.now().strftime("%H:%M:%S")
self.time_label.config(text=current_time)
self.root.after(1000, self.update_clock)
if __name__ == "__main__":
root = tk.Tk()
app = DigitalClockApp(root)
root.mainloop()