Redirecting the Python console output

22 views
Skip to first unread message

Tim Hellis

unread,
Oct 27, 2015, 1:36:52 PM10/27/15
to gui2py
I would like to redirect the output of from the Python console to a TextBox (or an other control if there is a better choice).

Basically, without boring you I have a Python program which I am giving a nice gui2py interface. However I would like to see the scripts output when I am looking at the Admin screen.

I have tried redirecting all output (by using sys.stdout) but the TextBox object does not seem to support a 'write' command.
Is there anyway to achieve this?


I would be grateful for any advice!

Thank you in advance.
Tim

br...@bradcan.homelinux.com

unread,
Aug 9, 2018, 1:12:40 PM8/9/18
to gui2py
Try something like:
       
style = wx.TE_MULTILINE | wx.TE_READONLY | wx.HSCROLL  # whatever
log = wx.TextCtrl(self, wx.ID_ANY, style=style)

sys.stdout=log  # redirect to log

Then to un-redirect
sys.stdout = sys.__stdout__
Reply all
Reply to author
Forward
0 new messages