printing from child process in Tkinter window

Dan Upton upton at
Fri Aug 28 01:35:04 CEST 2009

Hi all,

I've been messing with this for a couple hours now but can't make it work.
Basically I have a Tkinter GUI that creates a child process via
subprocess.Popen, and I would like to capture the child process's output to
display it in a Text widget in the GUI.  Relevant snippets:

def click_start: #launch from clicking a button in the gui
   self.apppipe = Popen(cmdString, shell=True, stdout=PIPE, stderr=PIPE)
   self.master.after(200, self.readAppStdout)

def readAppStdout(self):
   readers, writers, exceptionals = [self.apppipe.stdout],
[], [], 0.001)
   if readers != []:
      pipetext = self.apppipe.stdout.readline()
      self.appoutput.insert(END, pipetext) #self.appoutput is the Text

   (same for apppipe.stderr)
   self.master.after(200, self.readAppStdout)

I don't ever get any output in my window, even though I've waited long
enough that the application would otherwise have printed to the console
(based on its graphical outputs).  Any suggestions for what I'm doing wrong?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list