[wxPython-users] Re: Sizing flag

Robin Dunn robin at alldunn.com
Thu Feb 8 11:52:46 PST 2007


Rooney, Mike (ext. 324) wrote:
>> Please send a small sample of running code. It will make it easier for 
>> us to help you. It will also be shorter than explaining it in English :).
> 
> Okay, here is a running example. It will show 4 modals total. Click
> okay on each one to go to the next. The function in question is
> SetControl at the top. The first three controls look fine, but
> for the fourth one, the CheckBox is in the corner. I would like controls
> that can't expand all the way to be centered. Thanks!

The checkbox does expand just fine, you just can't see it because the 
(empty) label area is the same color as the panel's background.  But in 
in any case, this change will do what you want.

     def SetControl(self, editControl, center=False):
         sizer = wx.BoxSizer(wx.VERTICAL)

         if center:
             sizer.Add(editControl, 1, wx.ALIGN_CENTER_HORIZONTAL)
         else:
             sizer.Add(editControl, 1, wx.EXPAND)
         sizer.AddSpacer(10)
         sizer.Add(self.optionsBox, 0, wx.CENTER)
         sizer.AddSpacer(10)
         sizer.Add(self.buttonSizer, 0, wx.CENTER)
         sizer.AddSpacer(10)

         self.SetSizerAndFit(sizer)

...

         dlg = LeafEditDialog(title='CheckBox')
         dlg.SetControl( wx.CheckBox(dlg, -1, "the label"), True )
         dlg.ShowModal()


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





More information about the wxpython-users mailing list