Why Does .Hide()ing and .Show()ing Panels in wxPython Result in the Sizer Changing the Layout?

前端 未结 2 1301
不思量自难忘°
不思量自难忘° 2021-02-03 10:08

As referenced in my previous question, I am trying to make something slightly wizard-like in function. I have settled on a single frame with a sizer added to it. I build panel

相关标签:
2条回答
  • 2021-02-03 10:37

    I think I figured it out. Instead of calls to the Show and Hide methods of the panels, you need to call the Show and Hide methods of the root sizer:

    self.Show()
    

    becomes

    self.GetParent().GetSizer().Show(self)
    

    ...and so on.

    Also, after each call, you need

    self.GetParent().GetSizer().Layout()
    
    0 讨论(0)
  • 2021-02-03 10:50

    Yeah, I know this is already answered, but here you go anyway:

    You should only have to call Layout() on the panel's parent, so something like self.GetParent().Layout() should do the trick. See this article: http://www.blog.pythonlibrary.org/2010/06/16/wxpython-how-to-switch-between-panels/

    If you want the buttons to always show, create two panels in one vertical sizer. The one on top will show your panels and the one on the bottom will show the buttons. Then use PubSub or something to communicate between them.

    0 讨论(0)
提交回复
热议问题