Python Forum
[Tkinter] Tkinter Aproach of UserInput Feedback
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Tkinter Aproach of UserInput Feedback
#3
(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()
RichardeRicharde likes this post
Reply


Messages In This Thread
RE: Tkinter Aproach of UserInput Feedback - by woooee - Nov-24-2022, 05:44 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020