Hi, there,
I want to use wx.richtext.RichTextCtrl to display real-time(running-time) texts. But it seems wx.richtext.RichTextCtrl can not display texts until the task is done, please look at the following sample code. Did I miss something? However, I tried wx.TextCtrl and it can display texts during running time without any problem. In following code, you can switch two self.log to see difference.
Your clue is appreciated.
Eddy H.
import wx
import wx.richtext
import sys
class MyForm(wx.Frame):
def init(self):
wx.Frame.init(self, None, wx.ID_ANY, “wxPython Redirect Tutorial”)
Add a panel so it looks the correct on all platforms
panel = wx.Panel(self, wx.ID_ANY)
self.log = wx.richtext.RichTextCtrl(panel, wx.ID_ANY, size=(300,100), style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
#self.log = wx.TextCtrl(panel, wx.ID_ANY, size=(300,100), style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
btn = wx.Button(panel, wx.ID_ANY, ‘Push me!’)
self.Bind(wx.EVT_BUTTON, self.onButton, btn)
Add widgets to a sizer
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.log, 1, wx.ALL|wx.EXPAND, 5)
sizer.Add(btn, 0, wx.ALL|wx.CENTER, 5)
panel.SetSizer(sizer)
def onButton(self, event):
for i in range(3000):
self.log.WriteText(“You pressed the button!\n”)
self.Refresh();
Run the program
if name == “main”:
app = wx.App(False)
frame = MyForm().Show()
app.MainLoop()