Adding many scrolledpanels to one scrolledPanel in wxPython
Question: Level: Beginner

I am developing a GUI with wxPython on Windows 7 OS. Python version is 2.7 ad
wxPython version is 3. My GUI looks as shown in the image below:

![Screenshot](http://i.stack.imgur.com/ZpojA.png)

I would like to take some time to explain what I am trying to achieve. As you
mayhave noticed from the first image that there are 4 different scrolled
panels in my GUI named as `panel-1 to panel-4`. A vertical BoxSizer is applied
to each scrolled panel. Each scrolled panel in return contains a boxsizer and
a horizontal `wx.StaticLine`. The reason for using horizontal line was to make
it is easier for the user to read the values for a particular serial number.
(It will be easy for an user to read all the values in different panels for a
particular serial number.) Finally all these four scrolled panels are added to
a horizontal BoxSizer named as `panelSizer`. Currently the scrolled panels are
scrolling individually. One important thing is that all the scrolled panels
will every time contain same number of components/elements.

Problem:

I need a way so that I can add all these scrolled panels to one sizer or a
panel in such a way that there is only one scroll bar at right side and when I
scroll this scrollbar all the scrolled panels (panel-1 to panel-4) should
scroll simultaneously. I would like to have something like this:![image
2](http://i.stack.imgur.com/d1SVH.png)

I think this option is better from the GUI perspective. I have tried couple of
things like, I created a new scrolled panel named as `main panel`, and applied
the BoxSizer named as `panelSizer` (it contains all the panel from panel-1 to
panel-4) using `SetSizer()` function, but the scroll bar doesn't appears, even
the individual scroll bars doesn't appear! Also, I have checked that there are
enough components in the panels so that scroll bars appears. I tried to change
the four scrolled panels to simple panels and then add to the panelSizer and
then applied the sizer to the `main panel` but nothing solved the problem..

Can anyone suggest what is wrong with my approach? Any suggestion. Thank you
for your time.


Answer: Well I found the solution myself so here it goes.

I have to disable scrolling on the panels-1 to panel-4. This can be done by
not using `SetupScrolling()` method on them. Also, the scrolling should be
enabled on the mainPanel like this:

    
    
    mainPanel.SetupScrolling()
    

For an example: Consider that you have two scrolled panels named as `panel1`
and `panel2`. Now if you want to add these two scrolled panels to an other
scrolled panel named as `mainPanel`, then you first create these two scrolled
panels and then disable scrolling on them then add these two panels two a
sizer, then apply this sizer to the `mainPanel`. Code example:

    
    
    mainPanel = wx.lib.scrolledpanel.ScrolledPanel(self, -1,style=wx.SIMPLE_BORDER)
    mainPanel.SetupScrolling()
    panel1 = wx.lib.scrolledpanel.ScrolledPanel(mainPanel, -1, style=wx.SIMPLE_BORDER)
    panel2 = wx.lib.scrolledpanel.ScrolledPanel(mainPanel, -1, style=wx.SIMPLE_BORDER)
    panelSizer = wx.BoxSizer(wx.HORIZONTAL)
    panelSizer.Add(panel1)
    panelSizer.Add(panel2)
    mainPanel.SetSizer(panelSizer)
    

