Why does sizer.GetChildren return SizerItems instead of widgets?

Hi,

I was attempting to help someone on StackOverflow yesterday (see http://stackoverflow.com/q/12031522/393194) and they were trying to get the children of a BoxSizer using its GetChildren method. This returns a list of SizerItems instead of the actual widgets though. Is there a way to get the widgets like you do when you call a panel’s GetChildren method?

  • Mike

Hi,

···

On Wed, Aug 22, 2012 at 8:24 AM, Mike Driscoll <kyosohma@gmail.com> wrote:

Hi,

I was attempting to help someone on StackOverflow yesterday (see
wxPython: How to get sizer from wx.StaticText? - Stack Overflow) and they were trying to get the
children of a BoxSizer using its GetChildren method. This returns a list of
SizerItems instead of the actual widgets though. Is there a way to get the
widgets like you do when you call a panel's GetChildren method?

Because the 'children' of a sizer may not all be windows/widgets. They
may be other sizers, spacers, ect...

Each of the SizerItem's has a reference to the Window object it
manages if it has one. Use either the Window property or GetWindow
method.

Cody

GetWindow? I knew I should have tried that, but I figured that would just return the frame or panel. Thanks Cody!

  • Mike
···

On Wednesday, August 22, 2012 8:32:32 AM UTC-5, Cody Precord wrote:

Hi,

On Wed, Aug 22, 2012 at 8:24 AM, Mike Driscoll kyos...@gmail.com wrote:

Hi,

I was attempting to help someone on StackOverflow yesterday (see

http://stackoverflow.com/q/12031522/393194) and they were trying to get the

children of a BoxSizer using its GetChildren method. This returns a list of

SizerItems instead of the actual widgets though. Is there a way to get the

widgets like you do when you call a panel’s GetChildren method?

Because the ‘children’ of a sizer may not all be windows/widgets. They

may be other sizers, spacers, ect…

Each of the SizerItem’s has a reference to the Window object it

manages if it has one. Use either the Window property or GetWindow

method.

Cody