console redirection to Tkinter

Fabien Hénon ffjhenon at club-internet.fr
Sun Apr 21 18:50:31 EDT 2002


I want to use Tkinter to launch an external raytracer(POVRAY).
Like Python, it reads a script,
it spits out an image in a box and displays the line number which
is calculated to the console.
When the raytrace is over(after 1 second or 1 day), it outputs the stats
to the console as well.
I would like both outputs (line number and stats) to be redirected
to my Tkinter application.(That's where I get stuck)
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
  t.insert('1.0',"---out----")
  t.insert('1.0',pout)
  t.insert('end',"---err----")
  t.insert('end',perr)

mframe=Frame()
b=Button(mframe,text="Raytrace !",command=lance)
mframe.pack()
b.pack()
t=Text(mframe,width=20)
t.pack()
b.mainloop()
------------------cut here--------------------------



More information about the Python-list mailing list