This is a very simple solution I found to implement a scrolling text window in wxPython.
The problem is trying to set a StaticText widget to fit into some form of scrolling widget so that a large amount of text can be displayed in a scrolling text window. After trying out many methods, not getting the results that I want, I managed to find a solution. Which is to use a read-only multi-line TextCtrl.
self.textpanel = wx.TextCtrl(panel,
style=wx.TE_MULTILINE|wx.TE_READONLY)
Then, to set the text, just use:
self.textpanel.SetValue(s)
That's all! Just two lines of code.
No need to mess with ScrolledPanel or ScrolledWindow. I tried those, they do work, but it is a bit more complicated.
The problem is trying to set a StaticText widget to fit into some form of scrolling widget so that a large amount of text can be displayed in a scrolling text window. After trying out many methods, not getting the results that I want, I managed to find a solution. Which is to use a read-only multi-line TextCtrl.
self.textpanel = wx.TextCtrl(panel,
style=wx.TE_MULTILINE|wx.TE_READONLY)
Then, to set the text, just use:
self.textpanel.SetValue(s)
That's all! Just two lines of code.
No need to mess with ScrolledPanel or ScrolledWindow. I tried those, they do work, but it is a bit more complicated.
No comments:
Post a Comment