Christoffer Sørensen wrote:
Hi,
I am trying to have a panel with a number of collapsiblepanes filled
with controls.This panel should have scrollbars when the size of the open panes
exceed that of the size of the aui pane.I have tried having the panel derived from scrolledpanel and
scrolledwindow but I don't get any scrollbars.See attached file.
I have been struggling with this for quite some time now, so I could
appreciate some help.
class TestPanel(scrolled.ScrolledPanel):
def OnPaneChanged(self, evt=None):
self.SetupScrolling(scrollToTop=False)
def __init__(self,parent,size):
scrolled.ScrolledPanel.__init__(self, parent, -1,size=size)
mainSizer = wx.BoxSizer(wx.VERTICAL)
for j in range(5):
# First create the controls
cp = wx.CollapsiblePane(self, label="test",
style=wx.CP_DEFAULT_STYLE|wx.CP_NO_TLW_RESIZE)
parent = cp.GetPane()
sizer = wx.GridBagSizer(0,0)
self.Bind(wx.EVT_COLLAPSIBLEPANE_CHANGED,
self.OnPaneChanged, cp)
for i in range(10):
nameLbl = wx.StaticText(parent, -1, "Name:")
sizer.Add(nameLbl, (i,0))
name = wx.TextCtrl(parent, -1, "")
sizer.Add(name, (i,1))
parent.SetSizer(sizer)
mainSizer.Add(cp,0,wx.VERTICAL,0)
self.SetSizer(mainSizer)
self.SetupScrolling()
I changed it so the collapsible panes are direct children of the scrolled panel, used SetSizer instead of SetSizerAndFit, removed the mainSizer.SetMinSize call, and used SetupScrolling both in __init__ and in OnPaneChanged.
···
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!