Panels and Sizers

Robin,

I thought I’d tried some of those things, but obviously I didn’t try the right ones!

Thank you.

···

On Thu, Apr 3, 2008 at 3:44 PM, Robin Dunn robin@alldunn.com wrote:

Timothy Grant wrote:

More neophyte questions…

I have some code which creates a panel and paints on the panel. It works beautifully, but the panel takes up the whole window and now I want to add some other controls. After reading up on Layout, I discovered that I wanted a Sizer. I would put the Panel in the Sizer, and then below that I would put another Panel that contained my controls. Looking for examples I found some and I ended up with the following code.

If you look at MyFrame, you’ll see one line commented out. When that line is not commented and the three lines below it ARE commented things work correctly and I see my Window with a BLUE background. But when I use the Sizer code I end up with a Window with a grey background. I haven’t gotten as far as adding the next Panel, and other controls, because I apparently can’t get the one Panel added correctly.

It’s doing exactly what you are telling it to do! :wink:

The problem is that since the panel has no sizer of it’s own, no child widgets and/or no min size, then its “best size” will end up being a very small value and the frame’s sizer is using that value when deciding how to size and position it. You can either change the nature of the panel in one of the ways above to make the sizer act differently, or you can give some other parameters to the Add() method. For example, this will make the panel fill the frame in both directions, just like the frame does automatically when it has only one child:

    vbox.Add(MyPanel(self), 1, wx.EXPAND)

Robin Dunn

Software Craftsman

http://wxPython.org Java give you jitters? Relax with wxPython!


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users


Stand Fast,
tjg.