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

て烟熏妆下的殇ゞ 提交于 2019-11-30 03:46:33

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()

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!