[wxPython] How to rebuild a page containing controls because some of them have to be deleted?

Cliff Wells clifford.wells at comcast.net
Fri Oct 29 21:10:13 CEST 2004

On Fri, 2004-10-29 at 20:51 +0200, F. GEIGER wrote:
> I often use Notebook to structure my GUIs. Sometimes I have to provide a
> Settings page. Doing changes in this page influences other pages in such a
> way, that some controls have to change add or remove children or even have
> to be removed from the page at all.
> Yet I could not come up with a solid pattern how to do this. I tried to call
> DestroyChildren(), delete all ref's to them, and to set the page's sizer to
> None. This doesn't work very well. When I rebuild the page, at least the
> arrangement of the controls is not the same as before, which makes me think,
> that other things will go wrong in the long run too.

I use this technique with little issue (although I haven't tried it with
a wx.Notebook).  One thing you might try is to use an extra wx.Panel as
a container for the entire page.  So each page then would end up with a
single panel for the page, and each panel further containing *another*
single panel which contains your actual controls.  This way you can
simply destroy the second panel and recreate it and the layout is simple
enough that you shouldn't run into problems with sizers getting


Cliff Wells <clifford.wells at comcast.net>

More information about the Python-list mailing list