XRC: control in sizer in sizer won't expand

Can someone explain to me the difference between these two XRC examples.
The first one is a simple sizer on a panel, with a control that has
option=1 (growable control; expands in the direction of the sizer).

This works correctly.

Example two adds only one thing: another sizer containing the sizer. In
this example, nothing expands.

I can do this using the wxPython sizers API directly, but I can't figure
out why it doesn't work in XRC.

Finally, at the bottom is a little stub code to run both.

--- show_brokage.xrc ---
<?xml version="1.0" ?>
<resource>
  <object class="wxFrame" name="WORKS">
    <title></title>
    <object class="wxBoxSizer">
      <orient>wxHORIZONTAL</orient>
      <object class="sizeritem">
        <object class="wxButton" name="showbroken">
          <label>This button expands</label>
        </object>
        <option>1</option>
      </object>
    </object>
  </object>
  <object class="wxFrame" name="BROKEN">
    <title></title>
    <object class="wxBoxSizer">
      <orient>wxVERTICAL</orient>
      <object class="sizeritem">
        <object class="wxBoxSizer">
          <orient>wxHORIZONTAL</orient>
          <object class="sizeritem">
            <object class="wxButton" name="showworks">
              <label>This button doesn't expand - why?</label>
            </object>
            <option>1</option>
          </object>
        </object>
      </object>
    </object>
  </object>
</resource>

--- show_brokage.py ---
from wxPython.wx import *
from wxPython.xrc import *

app=wxPySimpleApp()
res=wxXmlResource('show_brokage.xrc')
res.LoadFrame(None, 'WORKS').Show(1)
res.LoadFrame(None, 'BROKEN').Show(1)
app.MainLoop()

···

__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com

Cory Dodt wrote:

Can someone explain to me the difference between these two XRC examples. The first one is a simple sizer on a panel, with a control that has
option=1 (growable control; expands in the direction of the sizer).

This works correctly.

Example two adds only one thing: another sizer containing the sizer. In
this example, nothing expands.

I can do this using the wxPython sizers API directly, but I can't figure
out why it doesn't work in XRC.

Because you don't allow the nested sizer to grow, and so it won't. You can give it the option=1, and/or wxGROW flag too.

···

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