[pygtk] Asynchronous access at output of os.popen() call

togix togix at libero.it
Thu Aug 21 17:09:00 WST 2008

Hi everyone,
at the end I'm close to the solution, thanks to both Albert and Pádraig for the suggestions.

Here is my PyGTK interface, modified importing the “subProcess.py” by Pádraig and workinf on process.outdata for displaying the output:
      process = subProcess.subProcess(cmd)
      while process.read(3) == 1:
            # process the output of called program
            textbuffer.insert_at_cursor("\n*" + process.outdata + "* [" + time.asctime() + "]")		
            while gtk.events_pending():
            process.outdata = ""

And with this part of code will keep the scroll at the bottom of the box (useful to always see the new lines):
      sw = gtk.ScrolledWindow()
      textview = gtk.TextView()
      vadj = sw.get_vadjustment()
      vadj.connect('changed', lambda a, s=sw: rescroll(a,s))
      def rescroll(adj, scroll):


More information about the pygtk mailing list