while trying to create a countdown timer, I have ran into a problem. I have based myself on Bryan Oakleys code (Making a countdown timer with Python and Tkinter?) I did not post the whole code because that would be quite long.
What I want my code to do:
Wait for x amount of seconds, stored in Wait and collected by the entry WaitE. Next, I want the wait_button to call the Countdown call. This class will create a label in its own tkinter window. After the countdown (= an x seconds delay) the main function will be recalled and change the flow.
What it does:
The code is executed without errors. A countdown takes place, and the flows are changed, but without a second delay and without opening a tkinter window.
Any help would be appreciated, I looked on the site but did not find anything that really helped to resolve my problem.
Stijn
def Wait_button(self):
"""This is part of a larger tkinter grid and is called after pushing a button"""
"""Wait for a set ammount of time before changing"""
self.Flow = self.Collect()
self.WaitE = int(self.WaitE.get())
Countdown(self.Flow, self.WaitE)
return()
class Countdown():
def __init__(self, Flow, WaitE):
self.master = Tk()
self.label = Label(self.master, text="", width=10)
self.label.pack()
self.remaining = WaitE
self.Flow = Flow
self.counting(Flow, self.remaining)
def counting(self, Flow, remaining = None):
print(Flow, "after init")
if remaining is not None:
self.remaining = remaining
if int(self.remaining) <= 0:
self.master.destroy()
Go = AskInput(root)
Go.Change_now(Flow)
else:
print(self.remaining, "-1")
self.label.configure(text="%d" % self.remaining)
self.remaining = self.remaining - 1
self.label.after(1000, self.counting(self.Flow))