I'm creating a program that keeps checking for change in a MySQL database, and according updates a GTK display. The part that keeps checking is in an infinite loop.
What I want is that once the GTK window has been closed, I can break out of the infinite loop.
But I don't know what condition to use for that. I've tried
if !window:
and
if window == None:
but in either case, it doesn't work.
The structure of my code is like this:
while True:
# my code
while gtk.events_pending():
gtk.main_iteration()
# something to exit here
window.connect("destroy", gtk.main_quit())
I don't know if placing "window.connect" there can cause a problem, because the window seems to close just fine. Also, if I placed it within the loop, or before the loop, I'd get a Runtime Error: called outside of mainloop.
So to re-iterate, how do I exit the infinite loop using the closure of the window as a condition? I don't want the user to have to use Ctrl + C.
Thanks in advance!