redirect console output to widget?
Lei Chen
llchen223 at hotmail.com
Sun Feb 10 19:12:14 EST 2002
Hi,
I want to redirect console output to a Text widget. So far the code I
wrote crashes on occasion. Attached is the portions of the code.
Thanks in advance for your help. Here are some more details: program
runs on WIN32; the console stream is fast and continuous (console
program runs 24x7)
#this function pipes input to an widget
def pipeToWidget(input, widget):
widget.delete('1.0', END)
while 1:
line = input.readline()
if not line: break
widget.insert(END, str(line))
widget.see(END)
widget.update()
def funcThread(widget):
input = os.popen(r'executeMe.exe', 'r')
pipeToWidget(input, wiget)
#uber-main
root = Tk()
widget = Text(root)
widget.pack(side=TOP, expand=YES, fill=BOTH)
thread.start_new(funcThread, (widget,))
#...Some more threads started here...
root.mainloop()
More information about the Python-list
mailing list