[wxPython] Border around wxSizer

I need to have a border around a wxSizer inside a dialog. I thought I could
apply a layout constraint on the wxSizer, but wxSizer is derived from
wxObject and has no SetConstraint() method.

What would be the best way to do this? Should I enclose the wxSizer within
a wxPanel and apply the constraint to the wxPanel?

Thanks

···

--
------------------
Sarel Botha
sjbotha@email.com
------------------

99 little bugs in the code, 99 bugs in the code,
          fix one bug, compile it again...
          101 little bugs in the code....

I need to have a border around a wxSizer inside a dialog. I thought I could
apply a layout constraint on the wxSizer, but wxSizer is derived from
wxObject and has no SetConstraint() method.

What would be the best way to do this? Should I enclose the wxSizer within
a wxPanel and apply the constraint to the wxPanel?

You just add the sizer into an outer sizer with the wxEXPAND | wxALL
flags set like this:

# your control and its sizer:
button = wxButton(dialog, -1, 'press me')
mybox = wxBoxSizer(wxVERTICAL)
mybox.Add(button, 0, wxCENTER)
  
# the border sizer (border 3 pixels thick in all directions):
border = wxBoxSizer(wxVERTICAL)
border.Add(mybox, 1, wxEXPAND|wxALL, 3)
border.Fit(dialog)

assuming that 'dialog' is your dialog instance.

Look at the .createDialog method in wxPython/lib/filebrowsebutton.py for
an example of how it's done; also, check out wxPython/demo/Sizers.py.

Regards,

Oliver

···

--
F. Oliver Gathmann, Ph.D.
CRI Inc., 80 Ashford St., 02134 Boston, MA, USA
phone: (617) 787-5700#224, fax: (617) 787-4488
e-mail: ogathmann@cri-inc.com