[wxPython] borders around components

Hi,

How does one put a border around a group of components to seperate
them? I would like it to look similar to the wxRadioBox demo. That
is-a 3d line, with a title at the top left.

The only way I can see to do it is put them in a panel with a sunken
border. This is sort of what I need but not quite.

Also, I am using a wxRadioBox. Is there a way to space it out a
little bit? It is packed so tight that the title is against the first
item without even a pixel in between, at least on gtk. I've looked in
the docs but I don't see anything. Thanks if anyone can help.

Mike

How does one put a border around a group of components to seperate
them? I would like it to look similar to the wxRadioBox demo. That
is-a 3d line, with a title at the top left.

wxStaticBox and for laying out the contents, wxStatixBoxSizer. One odd
thing to watch out for is that the controls inside the static box need to be
its siblings, not its children.

Also, I am using a wxRadioBox. Is there a way to space it out a
little bit? It is packed so tight that the title is against the first
item without even a pixel in between, at least on gtk. I've looked in
the docs but I don't see anything. Thanks if anyone can help.

Nope. Layout of the radio buttons is fixed (other than specifying number of
rows or columns) when you use a wxRadioBox.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!

Mike,

Actually there is another option. You can mimic wxRadioBox with manually laying out each wxRadioButton. Its not nearly as compact, but nice thing about it is that you can space things out as you see fit. Below is a complete body of a simple wxRadioBox. Hope it helps.

Bob

···

At 07:15 PM 4/4/2001 -0700, Mike Miller wrote:

> Also, I am using a wxRadioBox. Is there a way to space it out a
> little bit? It is packed so tight that the title is against the first
> item without even a pixel in between, at least on gtk. I've looked in
> the docs but I don't see anything. Thanks if anyone can help.

Nope. Layout of the radio buttons is fixed (other than specifying number of
rows or columns) when you use a wxRadioBox.

--------------

         box = wxBoxSizer(wxVERTICAL)
         box.Add(0,0,0,wxTOP,15) # put a space of 15 at top

         box1 = wxBoxSizer(wxHORIZONTAL)
         box2 = wxBoxSizer(wxHORIZONTAL)
         box3 = wxBoxSizer(wxHORIZONTAL)
         staticBox1 = wxStaticBox(self, 50, "load file", wxDefaultPosition,
                                  wxSize(-1,-1))
         boxSource1 = wxStaticBoxSizer(staticBox1, wxVERTICAL)

         self.b1 = wxRadioButton(self, 30, "previously saved graph", wxDefaultPosition,
                                 wxDefaultSize, wxRB_GROUP)
         self.b2 = wxRadioButton(self, 31, "Io/Is - single column")
         self.b3 = wxRadioButton(self, 32, "other")

         box1.Add(self.b1)
         box2.Add(self.b2)
         box3.Add(self.b3)
         boxSource1.Add(box1)
         boxSource1.Add(box2)
         boxSource1.Add(box3)

         box.Add(boxSource1, 0, wxEXPAND|wxLEFT|wxRIGHT|wxBOTTOM, 20)

         # add OK and Cancel buttons
         boxX = wxBoxSizer(wxHORIZONTAL)
         boxX.Add(0,0,0,wxTOP,15) # put a space of 15 at top
         okButton = wxButton(self,wxID_OK,"OK")
         okButton.SetDefault()
         cancelButton = wxButton(self,wxID_CANCEL,"Cancel")
         boxX.Add(10,20,0,wxEXPAND)
         boxX.Add(okButton,0, wxBOTTOM, 15) # pad only bottom with 15
         boxX.Add(15,20,0,wxEXPAND)
         boxX.Add(cancelButton,0, wxBOTTOM, 15) # pad only bottom with 15
         boxX.Add(5,20,0,wxEXPAND)

         box.Add(boxX,0,wxCENTER)

         self.SetAutoLayout(true)
         self.SetSizer(box)
         box.Fit(self)
         box.SetSizeHints(self)

     def getFileSelection(self):
         if self.b1.GetValue():
             return 0
         elif self.b2.GetValue():
             return 1
         else:
             return 2

     def setFileSelection(self, s):
         if s == 0:
             self.b1.SetValue(true)
             self.b2.SetValue(false)
             self.b3.SetValue(false)
         elif s == 1:
             self.b1.SetValue(false)
             self.b2.SetValue(true)
             self.b3.SetValue(false)
         else:
             self.b1.SetValue(false)
             self.b2.SetValue(false)
             self.b3.SetValue(true)

_________________________