Today I prepared something interesting. It is a GUI with countdown. See how does it work and try to analyze the code. Next modify it to gain new skills.
Counter code
This is the code of tkinter countdown timer visible above.
import tkinter, time root = tkinter.Tk() root.title("Counter GUI") countdown = 4 txt = "Counter " bg = tkinter.Label(master=root, bg="black", fg="white", font="Arial 70", text="{0}{1}".format(txt, str(countdown))) bg.pack() def starting(ev): global txt, countdown if ev == "Enter": while countdown != 0: time.sleep(0.5) countdown -= 1 bg["text"] = txt + str(countdown) bg.update() time.sleep(1) bg["text"] = "Done!" root.bind("Space", starting(ev="Enter")) root.mainloop()
I created a simple Tkinter label.
Then starting function with the iteration countdown. Feel free to use that 😉