How to redirect the stdio to a defined control using wx python

Hello,

I did set the log to SetActive to my control and I can write via the LogMessage()
but I cannot find a way to redirect the stdio to my control.

         #we set the standard to log to our log window
        wx.Log_SetActiveTarget(wx.LogTextCtrl(self.general_log.logger))
        print "TEST the log window"
        wx.LogMessage("QME-DEV Instantiated Sucessfully")
        #nice but cannot redirect the stdio and traceback to this windows..

I tried to play with the SetLogLevel and other things but with no luck.
I use the .RedirectStdio() but this is not what I need. i must be able to log the stdio in my own control - as after as I need to use it for some other things.

Any idea ?

Thanx

Robert

Hello,

I did set the log to SetActive to my control and I can write via the
LogMessage()
but I cannot find a way to redirect the stdio to my control.

         #we set the standard to log to our log window
        wx.Log_SetActiveTarget(wx.LogTextCtrl(self.general_log.logger))
        print "TEST the log window"
        wx.LogMessage("QME-DEV Instantiated Sucessfully")
        #nice but cannot redirect the stdio and traceback to this windows..

I tried to play with the SetLogLevel and other things but with no luck.
I use the .RedirectStdio() but this is not what I need. i must be able
to log the stdio in my own control - as after as I need to use it for
some other things.

Any idea ?

See the following interactive console stuff for how to "capture"
stdout/stderr.

- Josiah

import sys
import wx

stdout = sys.stdout

class foo:

... def write(self, data):
... stdout.write('test: %s\n'%(data.rstrip('\n')))
...

def printer():

... print "hello"
...

a = wx.App()
b = wx.Frame(None)
_ = b.Show(1)
sys.stdout = foo()
wx.CallAfter(printer)
a.MainLoop()

test: hello
test:

···

"Robert F. VERGNES" <rfv@lit-energy.com> wrote: