How to destroy the children of a wx.StaticBoxSizer

Hello,

I am successfully adding wx.StaticBoxSizers to a wx.BoxSizer dynamically, but I am having trouble destroying the children of the containing wx.BoxSizer. Please see the attached sample code of the destroy process I am failing at.

Please advise me on how to destroy the check boxes along with the static box.

System: Windows 7, wx 2.9.5.0, python 2.6

Thanks

untitled-3.py (1.07 KB)

Jason Terhune wrote:

Hello,

I am successfully adding wx.StaticBoxSizers to a wx.BoxSizer
dynamically, but I am having trouble destroying the children of the
containing wx.BoxSizer. Please see the attached sample code of the
destroy process I am failing at.

Because the children of the sizer are not the widgets, but wx.SizerItem objects. These have a GetWindow method that will return the window (if the item is managing a window and not a spacer or sizer) so you could use that if you want to clear it out by traversing the sizer items. Or you can always destroy the child widgets by traversing their parent window's child list of course.

···

--
Robin Dunn
Software Craftsman

Thanks. It works now.