title: Exit from infinite loop after gtk window closes
body: <p>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. </p>
  
  <p>What I want is that once the GTK window has been closed, I can break out of the infinite loop.</p>
  
  <p>But I don't know what condition to use for that. I've tried</p>
  
  <pre><code>if !window:
  </code></pre>
  
  <p>and</p>
  
  <pre><code>if window == None:
  </code></pre>
  
  <p>but in either case, it doesn't work. </p>
  
  <p>The structure of my code is like this:</p>
  
  <pre><code>while True:
  
      # my code
  
      while gtk.events_pending():
           gtk.main_iteration()
  
      # something to exit here
  
  window.connect("destroy", gtk.main_quit())
  </code></pre>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>Thanks in advance!</p>