My architecture is like this:
Frame -> PanelA -> SizerA
But when the user does certain things I want to hide PanelA/SizerA and put PanelB/SizerB in the frame and show it. I'm using Disable() and Hide() to get PanelA out of the way. Once PanelB is done, I want to put PanelA back in place using Enable() and Show() as PanelB is destroyed. I want to keep PanelA alive and unchanged while PanelB is active.
Everything is fine when the app comes up with PanelA showing. But as soon as I put PanelB in its place nothing works right. PanelA still shows behind PanelB and PanelB doesn't resize properly.
The problem goes away if I change it to:
Frame -> Panel0 -> Sizer0 -> PanelA -> SizerA
I prefer not to have that extra Panel0 if possible.
Any idea what I could be doing wrong? What is the canonical way to swap panels in a frame?
Platform Win7 x32, Py2.7.2, wxPy 2.9.2.4.
Thanks,
Michael
You don’t require Panel0, but you do require Sizer0. Otherwise, PanelA and PanelB will not be sized to fill the Frame. You are apparently relying on the fact that a Frame automatically resizes its child, if there is only one, to fill its client area. But if you have 2 Panels which are children of the Frame, this is broken, so you need Sizer0.
···
On Sat, Dec 31, 2011 at 9:47 PM, Michael Hipp michael@redmule.com wrote:
My architecture is like this:
Frame → PanelA → SizerA
But when the user does certain things I want to hide PanelA/SizerA and put PanelB/SizerB in the frame and show it. I’m using Disable() and Hide() to get PanelA out of the way. Once PanelB is done, I want to put PanelA back in place using Enable() and Show() as PanelB is destroyed. I want to keep PanelA alive and unchanged while PanelB is active.
Everything is fine when the app comes up with PanelA showing. But as soon as I put PanelB in its place nothing works right. PanelA still shows behind PanelB and PanelB doesn’t resize properly.
The problem goes away if I change it to:
Frame → Panel0 → Sizer0 → PanelA → SizerA
I prefer not to have that extra Panel0 if possible.
Any idea what I could be doing wrong? What is the canonical way to swap panels in a frame?
Platform Win7 x32, Py2.7.2, wxPy 2.9.2.4.
Thanks,
Michael
–
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en
–
Best Regards,
Michael Moriarity
Thanks. I thought on Windows, putting a sizer directly on a frame was bad form. Did I misunderstand that?
Thanks,
Michael Hipp
···
On 2011-12-31 9:17 PM, Michael Moriarity wrote:
You don't require Panel0, but you do require Sizer0. Otherwise, PanelA
and PanelB will not be sized to fill the Frame. You are apparently
relying on the fact that a Frame automatically resizes its child, if
there is only one, to fill its client area. But if you have 2 Panels
which are children of the Frame, this is broken, so you need Sizer0.
No, the problem is putting controls directly on a form. Sizers are OK, as long as they only contain other containers, such as Panels.
···
On Sat, Dec 31, 2011 at 10:20 PM, Michael Hipp michael@redmule.com wrote:
On 2011-12-31 9:17 PM, Michael Moriarity wrote:
You don’t require Panel0, but you do require Sizer0. Otherwise, PanelA
and PanelB will not be sized to fill the Frame. You are apparently
relying on the fact that a Frame automatically resizes its child, if
there is only one, to fill its client area. But if you have 2 Panels
which are children of the Frame, this is broken, so you need Sizer0.
Thanks. I thought on Windows, putting a sizer directly on a frame was bad form. Did I misunderstand that?
Thanks,
Michael Hipp
–
Best Regards,
Michael Moriarity
Ok. I was able to eliminate Panel0 so that gets rid of one layer. I did have to do quite a bit of trial-and-error in various calls to Update(), Refresh(), Layout(), etc. to get things to size and draw correctly, but ultimately was able to simplify it greatly from what had been there for years. It's working correctly in 2.9.3.1 also.
Thanks,
Michael
···
On 2011-12-31 9:22 PM, Michael Moriarity wrote:
No, the problem is putting controls directly on a form. Sizers are OK,
as long as they only contain other containers, such as Panels.
I’m not sure if your method is the same as mine, but you can check out my little tutorial on the topic here: http://www.blog.pythonlibrary.org/2010/06/16/wxpython-how-to-switch-between-panels/
I just put both panels into one sizer and hide one of the panels. Then I Show/Hide as appropriate and call the frame’s Layout().
···
Mike Driscoll
Blog: http://blog.pythonlibrary.org
Thanks, Mike. Good tutorial. My scheme now ends up being essentially the same except I do also do sizer.Detach(panel) so there is ever only one panel in the sizer. This seems simpler in my setup as I've got lots more panels to manage - mine is implemented as a stack to give it a sort of "z order".
Thanks,
Michael
···
On 2012-01-03 9:12 AM, Mike Driscoll wrote:
I'm not sure if your method is the same as mine, but you can check out my
little tutorial on the topic here:
wxPython: How to Switch Between Panels - Mouse Vs Python
I just put both panels into one sizer and hide one of the panels. Then I
Show/Hide as appropriate and call the frame's Layout().
Yeah, Detach() is definitely handy. I’ve used it before too for dynamic buttons. If you experience some annoying flicker, you might want to look into the Freeze and Thaw methods.
···
Mike Driscoll
Blog: http://blog.pythonlibrary.org
Yes, my code has Freeze and Thaw at numerous places - probably too many. On Windows the screen gyrations were just unbearable otherwise. I think Freeze/Thaw actually improves performance by letting the GUI rest until the housekeeping work is done.
Thanks,
Michael
···
On 2012-01-03 1:16 PM, Mike Driscoll wrote:
Yeah, Detach() is definitely handy. I've used it before too for dynamic
buttons. If you experience some annoying flicker, you might want to look into
the Freeze and Thaw methods.