title: PyGTK Multiprocessing and Updating GUI
body: <p>I am trying to enable and disable a stop button for audio playback in a GUI created using Glade PyGTK 2.0. </p>
  
  <p>The program basically works by running and external process to play the audio. </p>
  
  <p>I am using multiprocessing(as threading is too slow) and I can't get the stop button to disable. I understand this is due to processes not being able to access the memory shared by the gtk widget thread.</p>
  
  <p>Am I doing something wrong, or is there any way to enable the button once the process exits?</p>
  
  <pre><code>#!/usr/bin/python
  import pygtk
  import multiprocessing
  import gobject
  from subprocess import Popen, PIPE
  pygtk.require("2.0")
  import gtk
  import threading
  
  gtk.threads_init()
  
  class Foo:
      def __init__(self): 
          #Load Glade file and initialize stuff
  
      def FooBar(self,widget):
          self.stopButton.set_sensitive(True)#make the Stop button visible in the user section
          def startProgram():
              #run program
              gtk.threads_enter()
              try:
                  self.stopButton.set_sensitive(False) 
              finally:
                  gtk.threads_leave()
              print "Should be done now"
  
          thread = multiprocessing.Process(target=startProgram)
          thread.start()
  
  if __name__ == "__main__":
  prog = Foo()
  gtk.threads_enter()
  gtk.main()
  gtk.threads_leave()
  </code></pre>
  
  <p><strong>EDIT:</strong> Never mind, I figured it out. I had not implemented threading properly and that caused the lag. It works fine now. Just have to change the FooBar method to:</p>
  
  <pre><code>    def FooBar(self,widget):
          self.stopButton.set_sensitive(True)#make the Stop button visible in the user section
          def startProgram():
              #run program
              Popen.wait() #wait until process has terminated
              gtk.threads_enter()
              try:
                  self.stopButton.set_sensitive(False) 
              finally:
                  gtk.threads_leave()
              print "Should be done now"
  
          thread = threading.Thread(target=startProgram)
          thread.start()
  </code></pre>