I am writing a python tkinter application that interfaces with a C++ library that I am also writing. The C++ library contains a class that wraps some of GLUT's functions.
My main function (python) looks something like this:
import sys
import tkinter as tk
import myCustomCppLibrary
#This sets up the GLUT bindings.
myCustomCppLibrary.Initialize()
root = tk.Tk()
# ... some stuff
#Something in mainloop() eventually calls glutMainLoop()
root.mainloop()
myCustomCppLibrary.Finalize()
sys.exit(0)
Unfortunately, glutMainLoop
blocks root.mainloop()
, meaning that my tkinter GUI becomes unfunctional as soon as my GLUT window is launched.
I did try to add a std::thread
object to my wrapper class but glutMainLoop
appears to exit the entire process after exiting, meaning that running it in a thread is not conducive to a clean exit.
I was thinking that I could use GLUT's atexit
to signal to tkinter that it needs to close and join the thread, but ideally the process would not end when I close the GLUT window (I don't think this would give a clean exit either).
Is is possible to have these two loops run concurrently, and to do so cleanly?
I would like to avoid modifying GLUT's source code.