2

So I already have a nice wx.Frame built. It is totally functional. I wish to make it a scrollable area. I have looked on the wx python API and it said that the following code should do it:

    self.panel = wx.lib.scrolledpanel.ScrolledPanel(parent = self, id = -1)
    self.panel.SetupScrolling()


    self.panel = wx.Panel(self, -1)
    self.panel.SetBackgroundColour(wx.Colour(self.Red, self.Blue, self.Green))
    self.box = wx.FlexGridSizer(fileList.__len__(), 5, 5,5)
    self.FileObjects = []
    self.BatchProblemFileObjects = []

This creates scroll bars, but only AFTER I resize the window and only if there is a need for it. Is there anyway to make it so that I do not have to resize the window to make the scroll bars appear?

Thanks for your help.

(Running on python 2.7)

Mizmor
  • 1,391
  • 6
  • 21
  • 43
  • Have you tried `self.Layout()` (or, if that doesn't work, `self.panel.Layout()`)? It forces a bunch of things like size recalculations and redraws. It's the first thing I try when I have any wxPython layout problems. – acattle Jun 20 '12 at 01:13
  • I finally got to my dev machine and ried your code. I see the scrollbar both with any without the `Layout()` call I suggest above. Could you explain your problem in greater detail? – acattle Jun 20 '12 at 03:02
  • Hope the edit helped. Thanks acattle – Mizmor Jun 20 '12 at 18:16
  • Do you just want to scrollbars to be visible (but greyed out) or do you want your panel to be a default size? – acattle Jun 22 '12 at 00:55
  • I would rather the panel be a default size and if the content is too big for it the scroll bars should appear. – Mizmor Jun 22 '12 at 15:11
  • In my experience, that's exactly what `wx.lib.ScrolledPanel` does. Maybe try moving "set up scrolling" to the end of the init? Maybe also add `self.SetAutoLayout(True)`? – acattle Jun 22 '12 at 15:18
  • 2
    Why do you set `self.panel` twice? The first time as `wx.lib.scrolledpanel.ScrolledPanel` on line 1 then later as a `wx.Panel` on line 5. – jakebird451 Jun 24 '13 at 03:30

0 Answers0