XRC and wxStaticBox/Sizer

Hello

I'm trying to use xrced to set up a wx.StaticBox and wx.StaticBoxSizer.

Doing this in code, I would set it up this way (using what I have read and examples):

mybox = wx.StaticBox(self.panel, -1, "My Label")
boxsizer = wx.StaticBoxSizer(box, wx.VERTICAL)

This works fine, and I can then modify the wx.StaticBox label in code, i.e.: mybox.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD))

Trying to do this with xrced doesn't appear to work. For one thing, there doesn't seem to be a way to create a wx.StaticBox that can be added to a wx.StaticBoxSizer. Or vice versa. In either case, they both become children of the immediate parent, and xrced's test panel will show TWO static boxes. The one produced by the wx.StaticBox has a label, and a box, but I cannot put anything inside the box. I can, however, make modifications to the label using the xrced style panel. The one produced by the wx.StaticBoxSizer also has a label and a box, and I can put other windows inside this box, but I cannot modify the label.

To further confuse the issue (for me, at least), it actually seems that the wx.StaticBox is not really needed at all using xrced, because creating just a wx.StaticBoxSizer (which includes a label field? ... but not when coding directly?) works just fine. Except that the label is fixed, unmodifiable. Creating just a wx.StaticBox with no wx.StaticBoxSizer also displays appropriately, and I can modify the label, but I can't imagine what it would be used for since apparently nothing can be put in the box.

What am I missing here? I need to be able to accentuate the label (bold, larger font) in a couple of wxStaticBox windows in my program, and I'd like to continue with xrced.

Thanks for any insight!

linux
wxPython-2.6.3.2
wxGTK-2.6.3.2
Python-2.4.3

Peter van Loben Sels wrote:

Hello

I'm trying to use xrced to set up a wx.StaticBox and wx.StaticBoxSizer.

Doing this in code, I would set it up this way (using what I have read and examples):

mybox = wx.StaticBox(self.panel, -1, "My Label")
boxsizer = wx.StaticBoxSizer(box, wx.VERTICAL)

This works fine, and I can then modify the wx.StaticBox label in code, i.e.: mybox.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD))

Trying to do this with xrced doesn't appear to work. For one thing, there doesn't seem to be a way to create a wx.StaticBox that can be added to a wx.StaticBoxSizer. Or vice versa.

XRC creates the wx.StaticBox for you when you use a wx.StaticBoxSizer.

In either case, they both become children of the immediate parent, and xrced's test panel will show TWO static boxes. The one produced by the wx.StaticBox has a label, and a box, but I cannot put anything inside the box. I can, however, make modifications to the label using the xrced style panel. The one produced by the wx.StaticBoxSizer also has a label and a box, and I can put other windows inside this box, but I cannot modify the label.

To further confuse the issue (for me, at least), it actually seems that the wx.StaticBox is not really needed at all using xrced, because creating just a wx.StaticBoxSizer (which includes a label field? ... but not when coding directly?) works just fine. Except that the label is fixed, unmodifiable. Creating just a wx.StaticBox with no wx.StaticBoxSizer also displays appropriately, and I can modify the label, but I can't imagine what it would be used for since apparently nothing can be put in the box.

You can also use XRC without sizers and use absolute positions and sizes instead. So that is when you could use a plain wx.StaticBox from XRC.

What am I missing here? I need to be able to accentuate the label (bold, larger font) in a couple of wxStaticBox windows in my program, and I'd like to continue with xrced.

It's not pretty but you can get to the staticbox in the Python code and change it there. (Get the sizer by calling GetContainingSizer on one of the widets that it contains, and then call sizer.GetStaticBox.)

ยทยทยท

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