Currently I am able to display my python console output in wxPython GUI. Below is the code for it: -
class RedirectText(object):
def __init__(self,aWxTextCtrl):
self.out = aWxTextCtrl
def write(self,string):
self.out.WriteText(string)
self.console = wx.TextCtrl(self.window_2_pane_2, wx.ID_ANY, "Low Power Demo Suite [Version Beta]\nC:\Software\Python\Visualizer> Running Simulation...", style=wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
self.console.SetMinSize((600, 200))
self.console.SetBackgroundColour(wx.BLACK)
self.console.SetForegroundColour(wx.WHITE)
redir = RedirectText(self.console)
sys.stdout = redir
The code is working perfectly fine. However what I want is, I want to display the console output in WxPython upto a specific line only.
How can I do the same?
Thanks Regards, Tanmay
As you are redirecting sys.stdout
the easiest way would be to cancel that, based on a test on the console output or a line count, or whatever your criteria is.
Before you reassign sys.stdout
to redir
save the original setting with:
oldstdout = sys.stdout
Then whenever your criteria is hit, reapply it with:
sys.stdout = oldstdout