Search code examples
pythonuser-interfacewxpython

wxPython panel redraw in windows


I am trying to make several different pages where I need to show different texts and buttons. What I did was I created a panel, and then several sizers on it, and then in the next page, I destroyed the panel and recreated the panel again with different contents/sizers.

It worked well in Linux, but when I tried the same source in the windows, the first page was okay, but in the second page and onward, it seems the sizers were not applied.

I tried various .Update() and .Refresh(), but nothing seems working.

It seems only when I maximize the window the sizers get applied and the layout becomes normal. (Again, after panel.Destory() and a new panel generation, the layouts are messed up again.)

How do I make two different "pages" (where I click on a button and it goes to the second page) with different contents and sizers in Windows?


Solution

  • Calling Layout on the widget's parent is the best way to do this is you are adding or destroying widgets. Sometimes you also need to call Refresh() to make it redraw too, although that might only be required when you're using Freeze/Thaw.