axl456 axl456 - 1 month ago 4x
Python Question

scrollbar for statictext in wxpython?

is possible to add a scrollbar to a statictext in wxpython?

the thing is that i'm creating this statictext:

self.staticText1 = wx.StaticText(id=wxID_FRAME1STATICTEXT1,label=u'some text here',name='staticText1', parent=self.panel1, pos=wx.Point(16, 96),
size=wx.Size(408, 216),style=wx.ST_NO_AUTORESIZE | wx.THICK_FRAME | wx.ALIGN_CENTRE | wx.SUNKEN_BORDER)
self.staticText1.SetBackgroundColour(wx.Colour(255, 255, 255))
self.staticText1.SetFont(wx.Font(9, wx.SWISS, wx.NORMAL, wx.BOLD, False,u'MS Shell Dlg 2'))
self.staticText1.SetConstraints(LayoutAnchors(self.staticText1, False,True, True, False))

but later i use StaticText.SetLabel to change the label and the new text is too big to fit the window, so i need to add a scrollbar to the statictext..

i tried adding wx.VSCROLL to the style, and the scrollbar show up but cant scroll down to see the rest of the text..


wx.StaticText is designed to never respond to mouse events and never take user focus. Given that this is its role in life, it seems that a scrollbar would be inconsistent with its purpose.

There are two ways to get what you want: 1) You could use a regular TextCtrl with the style TE_READONLY (see here); or 2) you could make a scrolled window that contains your StaticText control.