python - Basic Tkinter countdown timer - Stack Overflow
Similar principle as furass solution already posted, but using a StringVar: import Tkinter def button_countdown(i, label): if i > 0: i -= 1 # schedule next call first to avoid time drifting away from 1s after many calls root. after(1000, lambda: button_countdown(i, label)) label. set(i) else: close() def close(): root. destroy() root = Tkinter. Tk() counter = 10 button_label = Tkinter. StringVar . . .
more
|