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
#1
Hi There,
I wrote a simple math game for children and because i think it get´s more played by my son if there is an gui interface i try to rewrite it in python with tkinter.

I did many hours with lots of trail and error. For Some things I could need a hint and kindly ask you experts here for your aproach on some of my Problems.

The Game starts with a screen where you choose or creat your player (Done and Working)
Then Next Screen comes where you choose your Level (Done and Working)
Then next screen comes and gives you the first mathtask to solve, by pressing enter the next one comes up until all tasks are done. Everything is stored in an sql db with sql alchemy

Now I want to change this process a little:

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

When I created my own pop up my Programm got Stuck somehow, when the pop up got´s destroyed i´m back to the other screen but again before sending the last Enter of task 25...

And even more important i want some direct feedback for the player, like if they made a mistake i want a pop up saying wrong or something...
Or Maybee there written result should turn red and the right one should be displayed in green besides....
right now you don´t know if your calcs are right or wrong.
I prefer the display in the same window, and I don´t want the programm to stop - so if you enter the right result it turns green and the next task appears almost right away, if you did it wrong it turns red and shows the right result in green for like 1 seconde and the next task appears... and so on.

I Hope you can nelighten me with your ideas of solving such a "Problem" or Problems - they are pretty similar (more or less) - in both I dont want to user to make aditionaly user inputs.

Thanks in advance and best regards
Richarde
Reply
#2
no ideas anyone?
Would be awasome somebody could give me a hint so i can make some progress on the programm.
Thx in advance
Reply
#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


Forum Jump:

User Panel Messages

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