This is a further mod to Mike Driscoll’s sizer tutorial from here
http://www.blog.pythonlibrary.org/2008/05/18/a-wxpython-sizers-tutorial/
After following Cody’s suggestion i- from my previous post regarding Mike’s Sizer Tutorial …
I’ve added a menu with two menu items.
When I call self.SetMenuBar(), the sizer layout gets compressed to the upper left corner.
When I comment out this call in MyForm().init()
THIS LINE KILLS THE SIZER LAYOUT
self.SetMenuBar(self.mainMenuBar)
THIS LINE KILLS THE SIZER LAYOUT
the layout looks like what I would expect.
Any help to what I’m doing wrong is appreciated.
Thanks
Including the call causes layout problems- I don’t see why.
I’ve made menus before and didn’t have this issue.
See attached example
Copy of driscoll_sizers_tut.py (3.61 KB)
Just move the " self.SetMenuBar(self.mainMenuBar)" line to the end of the init method and it should work. At least, it did on my machine. I don’t remember why that works though.
···
Mike Driscoll
Blog: http://blog.pythonlibrary.org
Yes, this works for me.
It would be good to understand why,
I have my code to generate the menus in their own methods, to help keep init from being so cluttered,
I guess it wont hurt to pull one line out and move that to the end of init()
···
On Wednesday, September 21, 2011 2:07:24 PM UTC-7, Mike Driscoll wrote:
Just move the " self.SetMenuBar(self.mainMenuBar)" line to the end of the init method and it should work. At least, it did on my machine. I don’t remember why that works though.
Mike Driscoll
Blog: http://blog.pythonlibrary.org
Aha! I knew it was something simple like that!
···
On Wed, Sep 21, 2011 at 6:40 PM, Cody codyprecord@gmail.com wrote:
Hi,
On Wed, Sep 21, 2011 at 5:02 PM, cappy2112 cappy2112@gmail.com wrote:
Yes, this works for me.
It would be good to understand why,
The panels own size is being managed by a sizer ‘topSizer’ while the
frame is not using a sizer to manage the panel. If you put the panel
‘self.panel’ in a sizer and then set that as the frames sizer it will
also fix the layout. Since without a sizer the frame will only manage
the layout of its first child.
Cody
Mike Driscoll
Blog: http://blog.pythonlibrary.org