title: Execution order with threads and PyGTK on Windows
body: <p>I'm having issues with threads and PyGTK on Windows.  According the the <a href="http://faq.pygtk.org/index.py?req=show&amp;file=faq21.003.htp" rel="nofollow noreferrer">PyGTK FAQ</a> (and my own experimentation), the only way to reliably update the GUI from a child thread is to use the <code>gobject.idle_add</code> function.  However, it can't be guaranteed when this function will be called.  How can I guarantee that the line following the <code>gobject.idle_add</code> gets called after the function it points to?</p>
  
  <p>Very simple and contrived example:
  <pre><code>import gtk
  import gobject
  from threading import Thread<br>
  class Gui(object):
      def __init__(self):
          self.button = gtk.Button("Click")
          self.button.connect("clicked", self.onButtonClicked)
          self.textEntry = gtk.Entry()
          self.content = gtk.HBox()
          self.content.pack_start(self.button)
          self.content.pack_start(self.textEntry)
          self.window = gtk.Window()
          self.window.connect("destroy", self.quit)
          self.window.add(self.content)
          self.window.show_all()<br>
      def onButtonClicked(self, button):
          Thread(target=self.startThread).start()<br>
      def startThread(self):
          #I want these next 2 lines to run in order
          gobject.idle_add(self.updateText)
          print self.textEntry.get_text()<br>
      def updateText(self):
          self.textEntry.set_text("Hello!")<br>
      def quit(self, widget):
          gtk.main_quit()</p>
  
  <p>gobject.threads_init()
  x = Gui()
  gtk.main()</pre></code></p>