C
citronelu
I made a small wxPython app that retrieves web data; for visual
logging I use a TextCtrl widget, and stdout is redirected to it,
something like this:
class RedirectOutput:
def __init__(self, objectTxtCtrl):
self.out = objectTxtCtrl
def write(self, string):
self.out.WriteText(string)
[...]
messages = wx.TextCtrl(panel, -1, "", size = (-1, 200), style =
wx.TE_MULTILINE | wx.TE_RICH, name = "messages")
myout = RedirectOutput(messages)
sys.stdout = myout
The web query is inside a function (def Execute), binded to a button.
To simplify the story, consider the function looks like this:
def Execute(self, evt):
print "Start query"
time.sleep(5)
The "Start query" message should show in the *messages* box when I
press the button. Instead, it shows only after the time.sleep(5)
delay.
If I don't use the wx.TE_RICH / wx.TE_RICH2 style on *messages*, the
text shows before the time.sleep(5)
I want to use wx.TE_RICH / wx.TE_RICH2 because of the 64k limitation
of the standard TextCtrl.
I'm using python 2.4.3 and wxpython 2.8.1.1 unicode, on WinXP SP2.
Windows extensions are also installed.
logging I use a TextCtrl widget, and stdout is redirected to it,
something like this:
class RedirectOutput:
def __init__(self, objectTxtCtrl):
self.out = objectTxtCtrl
def write(self, string):
self.out.WriteText(string)
[...]
messages = wx.TextCtrl(panel, -1, "", size = (-1, 200), style =
wx.TE_MULTILINE | wx.TE_RICH, name = "messages")
myout = RedirectOutput(messages)
sys.stdout = myout
The web query is inside a function (def Execute), binded to a button.
To simplify the story, consider the function looks like this:
def Execute(self, evt):
print "Start query"
time.sleep(5)
The "Start query" message should show in the *messages* box when I
press the button. Instead, it shows only after the time.sleep(5)
delay.
If I don't use the wx.TE_RICH / wx.TE_RICH2 style on *messages*, the
text shows before the time.sleep(5)
I want to use wx.TE_RICH / wx.TE_RICH2 because of the 64k limitation
of the standard TextCtrl.
I'm using python 2.4.3 and wxpython 2.8.1.1 unicode, on WinXP SP2.
Windows extensions are also installed.