Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion Digital_Clock/digital_clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def __init__(self, font=None):
self.set_font(font)
self.add_header()
self.add_clock()
self.add_date() # ✅ Added new method to show date
self.update_time_on_clock()

def create_window(self):
Expand Down Expand Up @@ -39,6 +40,19 @@ def add_clock(self):
'times', 90, 'bold'), bg='blue', fg='white')
self.clock.grid(row=2, column=2, padx=620, pady=250)

def add_date(self):
"""Add a date label below the clock."""
self.date_label = Label(self.window, font=('times', 40, 'bold'), bg='black', fg='white')
self.date_label.grid(row=3, column=2)
self.update_date_on_clock()

def update_date_on_clock(self):
"""Update the date displayed below the clock."""
currentDate = time.strftime("%d-%b-%Y")
self.date_label.config(text=currentDate)
# Update every midnight (24*60*60*1000 ms)
self.date_label.after(86400000, self.update_date_on_clock)

def update_time_on_clock(self):
"""Update the time displayed on the clock every second."""
currentTime = time.strftime("%H:%M:%S")
Expand All @@ -53,4 +67,3 @@ def start(self):
if __name__ == "__main__":
clock = DigitalClock()
clock.start()

Loading