views:

344

answers:

1

Hi...

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.SetBackgroundStyle(wx.BG_STYLE_SYSTEM)
    self.staticText1.SetFont(wx.Font(9, wx.SWISS, wx.NORMAL, wx.BOLD, False,u'MS Shell Dlg 2'))
    self.staticText1.SetAutoLayout(True)
    self.staticText1.SetConstraints(LayoutAnchors(self.staticText1, False,True, True, False))
    self.staticText1.SetHelpText(u'')

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..

+1  A: 

wx.StaticText is designed to never respond to mouse events and never take user focus. Given that this is it's 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.

tom10
thanks!the TextCtrl did the work perfectly...
axl456
You're welcome... I'm happy to help. If this solution answers the question for you, you might want to mark it as accepted (so we'll both get a few points, but also to communicate its status to others and to stay within the SO game plan, etc).
tom10