jonwright/pyopengltk

Animation not stopping when variable = False. it prints false but the animation does not stop.

ShaunKulesa opened this issue ยท 13 comments

while self.runv == True:
self.app.animate = 1
self.app.after(100, self.app.printContext)
self.app.mainloop()
else:
print("false")
self.app.animate = 0
self.app.after(100, self.app.printContext)
self.app.mainloop()

updated code but animation still carrying on. and yes the loop does work. it prints true and false when needed.

while self.runv == True:
      print("true")
      self.app.animate = 1
     self.app.after(100, self.app.printContext)
     self.app.mainloop()

print("false")
self.runv = False
self.app.animate = 0
self.app.after(100, self.app.printContext)
self.app.mainloop()

I have a feeling its because you cant animate and stop animating mid way through running a program.

@einarf i swear that wasn't working earlier, now that i formatted it is it easier to understand my issue?

How are you updating the variable after you called mainloop? Usually there needs to be a callback from the gui loop. E.g. when does it know to start and stop animation?

I add a function to a button to update self.runv. I'll upload my code to a github.

I sent you a pull request. You need to call tkExpose or _display to trigger the animate loop.

Thank you so much, you are a great person.

@jonwright i see this has tk.expose, are all of the things on here relevant?
http://pyopengl.sourceforge.net/pydoc/OpenGL.Tk.html

This code was written to avoid needing to recompile togl. Hopefully this is vaguely compatible, most of the code comes from there.

@jonwright what method would i use to reset an animation?

nothing on here works except "keys" which returned nothing, http://pyopengl.sourceforge.net/pydoc/OpenGL.Tk.html.