console redirection to Tkinter

Eric Brunel eric.brunel at pragmadev.com
Tue Apr 23 08:27:41 EDT 2002


Fabien Henon wrote:
> When I uncomment the outr=pout.rea.....my app gets stuck.
> The t.insert('1.0',pout) and t.insert('end',perr) do not give me what I
> expect.
> 
> 
> What shall I do ?
> Thanks for any advice.
> 
> 
> ------------------cut here--------------------------
> #!/usr/bin/env python
> from Tkinter import *
> import popen2
> 
> def lance():
>   cmd= "x-povray +i/mnt/win_c/Utile/pyvon/7.pov +w320 +h240 -f +dgt +p"
>   run = popen2.Popen3(cmd)
>   pout=sys.stdout
>   perr=sys.stderr
> #  outr=pout.readlines() # when this

If you do that, sys.stdout and sys.stderr get the standard output and the 
standard error on the *current* process, i.e. your Python script. This is 
indeed not what you want. To get the standard and error output of the child 
process, you should do:

pout = run.fromchild
perr = run.childerr

HTH
-- 
- Eric Brunel <eric.brunel at pragmadev.com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com




More information about the Python-list mailing list