I am attempting to make a clock using python's Tkinter. It works but not in the way I intended. Once the user enters the amount of time that needs to be counted down from, the action is performed but the actual countdown isn't being shown. I would like for the user to have the ability to watch the numbers go all the way until 0. Any help is greatly appreciated.
import time from tkinter import * root = Tk() def countdown(t): ts = int(t) while ts > 0: timer = Label(timerFrame, text = ts) ts-=1 timer.pack() time.sleep(1) if ts ==0: timer.destroy() completeTimer = Label(timerFrame, text="Time is complete") completeTimer.pack() timerFrame = LabelFrame(root, padx=50, pady=50, bd=0) timerFrameText = Label(timerFrame, text="Enter time in seconds for countdown", font=("Arial", 20, "bold") ) countdownBox= Entry(timerFrame, bd=3) submitCountdown = Button(timerFrame, padx=5, pady=5, text="Submit", font=("Arial", 20), command= lambda:countdown(countdownBox.get()) ) timerFrame.pack() timerFrameText.pack() countdownBox.pack() submitCountdown.pack() root.mainloop()
root.update()aftertime.sleep()