Can't get ScrolledPanel to layout properly.

Hi All,

I'm trying to use ScrolledPanel in a resizable window and not having
much luck getting it to layout properly. I took a nice simple
StaticBoxSizer example from
[http://www.java2s.com/Tutorial/Python/0380__wxPython/0780__StaticBoxSizer.htm]
and modified it into a small example [http://pastebin.com/PwH8wc43]
that shows a StaticBoxSizer containing nine buttons.

So far, so good. What I want to do now is to place a ScrolledPanel
*inside* the StaticBoxSizer such that as the main window is resized
the StaticBoxSizer will conform to the new size, but the buttons
inside the StaticBoxSizer will remain the original size and the
ScrolledPanel will allow scrolling if the sizer is too small to show
all buttons. My failed attempt at this is
[http://pastebin.com/XtMkuzPA]. I'm sure it's my weak sizer-fu at
fault here, but I've been spinning my wheels on this for a couple of
days. Can anyone help me out?

TIA
Ross

Hello Ross,

here’s what you want.

Jcie.

wx.lib.scrolledpanel__OK.py (1.22 KB)

You were assigning items to the wrong sizer and/or sizers to the wrong window. Compare your code to the attached. A sizer can only manage items parented by the window that the sizer is assigned to, or sub-sizers that are managing other children of the same window.

spsizer.py (1.16 KB)

···

On 9/20/11 8:51 PM, Ross Wilson wrote:

Hi All,

I'm trying to use ScrolledPanel in a resizable window and not having
much luck getting it to layout properly. I took a nice simple
StaticBoxSizer example from
[http://www.java2s.com/Tutorial/Python/0380__wxPython/0780__StaticBoxSizer.htm\]
and modified it into a small example [http://pastebin.com/PwH8wc43\]
that shows a StaticBoxSizer containing nine buttons.

So far, so good. What I want to do now is to place a ScrolledPanel
*inside* the StaticBoxSizer such that as the main window is resized
the StaticBoxSizer will conform to the new size, but the buttons
inside the StaticBoxSizer will remain the original size and the
ScrolledPanel will allow scrolling if the sizer is too small to show
all buttons. My failed attempt at this is
[http://pastebin.com/XtMkuzPA\]. I'm sure it's my weak sizer-fu at
fault here, but I've been spinning my wheels on this for a couple of
days. Can anyone help me out?

--
Robin Dunn
Software Craftsman

Thanks guys.

This is going to be part of a larger custom widget I'm writing
involving 4 examples of the StaticBox+ScrolledPanel thing inside
nested MultiSplitterWindow widgets.

At least, that's the plan :slight_smile:

Ross