XRC: can you get a reference to a sizer?

If you use an XRC file, is there a way to obtain a reference to a sizer from within your program so you can dynamically add items to it later? XRCed doesn't have an "ID" field for it, so if it's possible, it must be done differently than normal.

My situation is that I have a few "telephone number" fields in the program I'm making, and instead of creating duplicate XRC code for each one, I thought I could make a single bit of code like this:

<object class="wxBoxSizer">
       <orient>wxHORIZONTAL</orient>
       <object class="sizeritem">
         <object class="wxTextCtrl" name="areaCode">
           <size>30,20</size>
         </object>
       </object>
       <object class="sizeritem">
         <object class="wxStaticText">
           <label> - </label>
         </object>
         <flag>wxALIGN_CENTRE</flag>
       </object>
       <object class="sizeritem">
         <object class="wxTextCtrl" name="phoneNumberPrefix">
           <size>30,20</size>
         </object>
       </object>
       <object class="sizeritem">
         <object class="wxStaticText">
           <label> - </label>
         </object>
         <flag>wxALIGN_CENTRE</flag>
       </object>
       <object class="sizeritem">
         <object class="wxTextCtrl" name="phoneNumberSuffix">
           <size>40,20</size>
         </object>
       </object>
     </object>

But this can't be a top-level widget, so I'm not sure where it would go anyway.

And then just add that to the larger sizer that contains all the other fields. This way I can work with just a single design for any telephone fields and add it anywhere I want. Unless there's an even better way?

Thanks.

John Salerno wrote:

If you use an XRC file, is there a way to obtain a reference to a sizer from within your program so you can dynamically add items to it later? XRCed doesn't have an "ID" field for it, so if it's possible, it must be done differently than normal.

They way it is normally done is to either call the GetSizer method on the window that owns the sizer, or call the GetContainingSizer method on a window that is managed by the sizer.

···

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

Robin Dunn wrote:

John Salerno wrote:

If you use an XRC file, is there a way to obtain a reference to a sizer from within your program so you can dynamically add items to it later? XRCed doesn't have an "ID" field for it, so if it's possible, it must be done differently than normal.

They way it is normally done is to either call the GetSizer method on the window that owns the sizer, or call the GetContainingSizer method on a window that is managed by the sizer.

Thanks!