Nov-24-2022, 05:44 PM
(This post was last modified: Nov-24-2022, 06:19 PM by Yoriz.
Edit Reason: Fixed quote
)
(Nov-20-2022, 07:16 PM)RichardeRicharde Wrote: Lets say you get 100 Tasks in this level, then you should get
4 times 25 tasks and have a little break for some TIME - so I want to have a Countdown Screen / PopUp in Between
Use a Message for a popup. A countdown is a simple label that gets updated using the after() method. This program is something that demonstrates a countdown timer. The red or green "light" would be a circle on a canvas. Post code for more assistance.
import tkinter as tk class TimedInput(): def __init__(self): self.top = tk.Tk() self.top.title("Test of After") self.top.geometry("200x150+10+10") tk.Label(self.top, text="you have 20 seconds" ).pack(side="top") self.lab=tk.Label(self.top, width=3) self.lab.pack(side="top" ) tk.Label(self.top, text="--------------------" ).pack(side="top") self.ctr = 20 self.entry_1 = tk.Entry(self.top, width=15) self.entry_1.pack(side="top") self.entry_1.focus_set() tk.Button(self.top, bg="orange", text="Get Entry", command=self.entry_get, ).pack(side="bottom") self.top.after(100, self.increment_counter) self.top.mainloop() def entry_get(self): print("Entry is", self.entry_1.get()) self.top.quit() def increment_counter(self): self.ctr -= 1 self.lab.config(text=self.ctr) if self.ctr > 0: self.top.after(1000, self.increment_counter) else: print("\n timing loop ended") self.top.quit() ##==================================================================== if __name__ == '__main__': CT=TimedInput()