I'm working on countdown timer with GUI and I'm trying to copy the GUI of Windows 10 coundown timer app. The GUI part is almost done and only the execution part remains:
def start_countdown():
global hours, minutes, seconds, timer
user_input = (int(hours)*60*60 + int(minutes)*60 + int(seconds))
timerrr = int(user_input)
while timerrr > 0:
minutes, seconds = divmod(timerrr, 60)
hours, minutes = divmod(minutes, 60)
timer.config(text=str(hours).zfill(2) + ":" + str(minutes).zfill(2) + ":" + str(seconds).zfill(2))
print(str(timer.cget("text")) + "\r", end=str(timer.cget("text")))
time.sleep(1)
timerrr -= 1
timer.after(1, start_countdown)
if timerrr == 0:
print("\r""time's up!!!")
showinfo("countdown clock", "Time's Up!!!")
This is the function that is supposed to perform the countdown step on the press of the button. The "timer" label doesn't display the updates after every second as I used the .after()
but by printing the same, I can see the countdown is working in console/terminal.