fredrik at pythonware.com
Fri Jun 27 12:47:58 CEST 2003
H.S. Art wrote:
> I have a sript that runs very well. I do my output to the python shell
> with the print command. That works well, too.
> print 'Error occured ' + str(i+1)
> No I want to have my output into a textctrl frame in a window. I start
> my script by pushing a button in my window. It starts fine but I can't
> see any output. For test purposes I added the following code to the
> event handler of the button:
> This produces output to my text ctrl window. So I replaced all 'print'
> commands in my script with 'self.textCtrl1.WriteText ...'
someone else will have to sort the variable scoping issues for you ,
but in the meantime, you could try the following little trick.
1) at the top of your program, import the "sys" module:
2) in the event handler, add the following redirection code:
# redirect output to my window
def __init__(self, window):
self.write = window.WriteText
sys.stdout = redirect(self.textCtrl1)
1) the following links might be somewhat helpful:
More information about the Python-list