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

F

F. GEIGER

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.

For now I issue a dialog telling the user, that he has to restart the app -
not very professional looking...

So, how is this done best?

Kind regards
Franz GEIGER
 
C

Cliff Wells

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
confused.

Regards,
Cliff
 
F

F. GEIGER

Cliff Wells said:
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
confused.

I thought about an extra panel too, shouldn't be a problem with Notebook
either. So if this is how it is done, I'll go for it.
Regards,
Cliff

Many thanks for your quick reply!

Kind regards
Franz

 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top