Tkinter+popen4+windows leads to unwanted window

Patrick L. Nolan pln at razzle.Stanford.EDU
Thu Dec 18 02:15:47 EST 2003


We have a python+Tkinter program that works properly on
Linux, but when moved to Windows (XP) it behaves in a
strange way.  There's a section like this:

(child_out, child_in) = popen2.popen4(cmd)
line = child_out.readline()
while line:
    do_something_with(line)
    line = child_out.readline()

The program named in the string cmd is a C++ 
application which writes lines of text to its
standard output.
The function do_something_with() displays the output
in a text window.

When I run this script on Windows XP with a recent
version of Active State python, nothing appears in
the text window.  Instead a new command tool window
opens, and all the text appears there.  When the
program (cmd) terminates, the command tool remains,
ready to accept commands.  The Tkinter window locks
up, with its menu bar blanked out.  The python
process burns 100% of the cpu time.

Apparently the child_out "file" returned by popen4 
isn't really passing its data to the python script.
It seems to be going directly to a command tool,
and I would guess that readline() is in an infinite
loop.

Is there some way to deal with this?

-- 
*   Patrick L. Nolan                                          *
*   W. W. Hansen Experimental Physics Laboratory (HEPL)       * 
*   Stanford University                                       *




More information about the Python-list mailing list