开发者

wxPython panel redraw in windows

开发者 https://www.devze.com 2023-02-20 01:03 出处:网络
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 th

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 n开发者_StackOverflowormal. (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?


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.


It seems there are better ways to do this, but panel.Layout() solved the problem for now. :)


I agree with using Layout(), but might I suggest just hiding the unused panel instead of destroying it? Using the Show()/Hide() functions of the sizer, you can add both side-by-side and just hide the unused panel instead of destryong it and recreating it each time?

0

精彩评论

暂无评论...
验证码 换一张
取 消