python - Tkinter - Code is executed without tkinter reacting -
this question has answer here:
while trying create countdown timer, have ran problem. have based myself on bryan oakleys code (making countdown timer python , tkinter?) did not post whole code because quite long.
what want code do:
wait x amount of seconds, stored in wait , collected entry waite. next, want wait_button call countdown call. class create label in own tkinter window. after countdown (= x seconds delay) main function recalled , change flow.
what does:
the code executed without errors. countdown takes place, , flows changed, without second delay , without opening tkinter window.
any appreciated, looked on site did not find helped resolve problem.
stijn
def wait_button(self): """this part of larger tkinter grid , called after pushing button""" """wait 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 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))
solved tigerhawkt3.
"try replacing line after self.label.after(1000, lambda: self.counting(self.flow))"
Comments
Post a Comment