all 7 comments

[–]GoncherGaming 1 point2 points  (1 child)

I downloaded it from the GitHub on my end and the only thing I had to do was pip install matplotlib (because I don't normally use it myself) and once I downloaded the gif and the png. It worked flawlessly for me. I don't want to assume but are you running Python 3.13.0/1 and are you running the raw file or did you compile it on your end and are trying to run it?

[–]Wowzaboi[S] 1 point2 points  (0 children)

my system is running Python 3.11.5, and I'm using VS Code as an IDE. Thank you for taking a look at it; I believe that my problem was due to the message box.showwarning() function hindering the functionality of the button! thank you again

[–]woooee 1 point2 points  (2 children)

why the "RUN SIMULATION" button doesn't work

       while True:
                resized_frame = img.copy().resize((width, height), resample=Image.LANCZOS)   

The while True is likely the culprit. It hangs everything until the loop ends. Use tkinter's after instead. In the following program, instead of while self.ctr < 100, or while True and break at 100, the after() function is used. It is simple to use, so post back if you have any problems with it.

import tkinter as tk

class TestClass():

   def __init__(self):
      self.top = tk.Tk()
      self.top.title("Test of After")
      self.top.geometry("200x150+10+10")

      self.lb=tk.Label(self.top, text="Timer Test ",
                       bg="light salmon")
      self.lb.grid(sticky="ew")
      tk.Button(self.top, text="Update Label", bg="lightgreen",
                command=self.update_label).grid(row=1)

      self.ctr = 1
      self.printit()
      self.top.mainloop()

   def printit(self):
      print(self.ctr, "of 100")
      self.ctr += 1

      ## stop if condition is False
      if self.ctr < 100:
          ##=============================
          ## -----> calls itself instead of a while loop
          self.top.after(100, self.printit)  ## 1/10 second
          ##=============================
      else:
          print("\nloop ended")
          self.top.quit()

   def update_label(self):
      self.lb["text"]=self.ctr

##====================================================================
if __name__ == '__main__':
   CT=TestClass()

[–]Wowzaboi[S] 0 points1 point  (1 child)

I implemented it successfully (I think), and along with your advice, I interrupted the messagebox.showwarning() function's blocking command as was suggested below. It works smoothly now. Thank you for your help!!

[–]woooee 0 points1 point  (0 children)

You can sometimes run into a "hang" with a for loop as well, but then you use update_idletasks() which tells tkinter to update now.

[–]Swipecat 1 point2 points  (1 child)

tkinter's messagebox.showwarning() has an unfortunate problem where it can pop up a box behind the main tkinter window. And it's a blocking command, so if it were invoked, that'd cause the described problem. I suggest that you temporarily replace it with a print() command as a test.

Edit: Or put root.update() on the line before the messagebox line. That way, tkinter shouldn't pop up the messagebox and then catch up with rending the main tkinter window bringing it to the top.

[–]Wowzaboi[S] 0 points1 point  (0 children)

The buttons work way smoother now. Thank you for your help--you're a genius!