-1

This is the code I have written, I don't understand why but nothing appears on my canvas.

def countdown():
    for n in range(5, 0, -1):
        nr = Label(root, text=n, font="helvetica 25 bold", bg="white")
        nr.place(x=590, y=420)
        nr.destroy()
Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
atlanta
  • 11
  • 3
    Might it be because you immediately destroy it? – infinitezero Oct 24 '21 at 09:43
  • If this is all the code you wrote, you never import anything, you never create a root window, you never call `mainloop`, and you never call your function. – Bryan Oakley Oct 25 '21 at 03:30
  • To add to the previous answers, because you have this inside a loop, the GUI doesn't have a chance to redraw with the new label. There is also no time delay between each number so from a human perspective the numbers won't be visible. – scotty3785 Oct 25 '21 at 13:46
  • Does this answer your question? [Making a countdown timer with Python and Tkinter?](https://stackoverflow.com/questions/10596988/making-a-countdown-timer-with-python-and-tkinter) – scotty3785 Oct 25 '21 at 13:47

1 Answers1

0

Use root.after(timer, function). Best way to do it s calling root.after(1000, your_func, count-1) your_func should configure the text of the label to "count".