When the start timer is called by the button click, how is it that the lines following the count_down function call are executed immediately before the counter is completed and returned?
Also, if we double click the start button it behaves weirdly.
Please explain the program flow in event-driven programs in python.
from tkinter import *
import math
def start_timer():
work_sec = 15
count_down(work_sec)
timer_label.config(text="Work", fg="red")
print("Debug")
def count_down(count):
count_min = math.floor(count/60)
count_sec = count % 60
canvas.itemconfig(timer_text, text=f"{count_min}:{count_sec}")
if count > 0:
window.after(1000, count_down, count-1)
window = Tk()
timer_label = Label(text="Timer", fg="green", font=("Courier", 48, "bold"))
timer_label.pack()
canvas = Canvas(width=300, height=250, bg="black")
timer_text = canvas.create_text(150, 125, text="00:00", fill="white", font=("Arial", 35))
canvas.pack()
start_button = Button(text="start", command=start_timer)
start_button.pack()
window.mainloop()