Multiple panels within a frame (sizer question)

I finally figured this out. I still don't completely
understand the parameters for the call to Add. The
relevant code was:

................
panel1 = ComboBoxPanel(self,-1, size=(100,100),
style=wxSUNKEN_BORDER)
        panel2 = SecondPanel(self, -1, size=(100,100),
style=wxSUNKEN_BORDER)

        box = wxBoxSizer(wxVERTICAL)
        box.Add(panel1, 0,
wxGROW>wxALIGN_CENTER_VERTICAL|wxALL, 2)
        box.Add(panel2, 1,
wxGROW>wxALIGN_CENTER_VERTICAL|wxALL, 2)
...............

I had to change the 0 in the box.Add call for panel2 to
a 1. I have looked for clarification of the parameters
but the wxWindow site is for C++ and that is a bit
confusing. Is there a clear explanation of this
somewhere? Or can someone just hook me up with an
explanation of these arguments?

--vicki

> I am trying to get a couple of panels to show up
within
> one frame. I think I am having trouble with the

sizer

> stuff and they are writing over each other. Can
someone
> take a look at the attached code please? I am

getting

···

> better at this, and it seems drastically easier than
> Tkinter.
>
> --vicki

vicki@stanfield.net wrote:

I finally figured this out. I still don't completely
understand the parameters for the call to Add. The
relevant code was:

................
panel1 = ComboBoxPanel(self,-1, size=(100,100),
style=wxSUNKEN_BORDER)
        panel2 = SecondPanel(self, -1, size=(100,100),
style=wxSUNKEN_BORDER)

        box = wxBoxSizer(wxVERTICAL)
        box.Add(panel1, 0,
wxGROW>wxALIGN_CENTER_VERTICAL|wxALL, 2)
        box.Add(panel2, 1,
wxGROW>wxALIGN_CENTER_VERTICAL|wxALL, 2)
...............

I had to change the 0 in the box.Add call for panel2 to
a 1. I have looked for clarification of the parameters
but the wxWindow site is for C++ and that is a bit
confusing. Is there a clear explanation of this
somewhere? Or can someone just hook me up with an
explanation of these arguments?

--vicki

See

http://wiki.wxpython.org/index.cgi/UsingSizers

and the included link to the wxDesigner tutorial.

Briefly, the second parameter, proportion, (but called option in later versions and possibly still in wxPython) is a weight which determines how the different controls you add to the sizer share the available size in the main direction of the box sizer (i.e. vertical for wxVERTICAL). If the proportion for a given control is 0, then that item will use the default size for that control (so, for a button, enough to hold the text). Otherwise, all controls with non-zero proportion share the remaining space in proportion to their proportion values (i.e. two controls with proportion 1 will get equal space, one with proportion 2 will get twice as much space, etc.).

The third parameter, flag, has two functions (which is a confusing design). First, it determines how the controls in the sizer grow in the perpendicular direction. The choices are 0 (doesn't grow), wxGROW or wxEXPAND (grow to fill the space), and wxSHAPED (grow to preserve the original aspect ratio of the control as it resizes in the main direction). Second, it determines how the control is aligned within the available space both vertically and horizontally (wxALIGN_CENTER, wxALIGN_TOP, etc.). You make a choice for perpendicular growth and a choice for alignment and combine the two choices with a bitwise or (e.g. wxGROW | wxALIGN_CENTER).

The fourth parameter determines how large a border the sizer leaves around a control (in pixels).

David

And only kicks in for the sides that you specify in the previous flags:

  wxLEFT>wxRIGHT # border on the sides, but not top and bottom
  wxALL # a convience for all sides

I think it would be more readable if those had '_BORDER' in them or were
put in a separate keyword arg. In any case, don't forget about them!

···

On Friday 18 April 2003 12:11 pm, David C. Fox wrote:

The fourth parameter determines how large a border the sizer leaves
around a control (in pixels).

--
Chuck
http://ChuckEsterbrook.com