Thanks, but is there maybe a more general solution? The example shows four pop-ups to demonstrate how the other controls correctly work, but in reality the method that calls SetControl has no idea of what the control is, it could be anything. I could do instance checking or something but that isn't a very attractive solution. The way it works in our application is the method creating the dialog calls a GetEditWidget method which returns a wx control, which it passes to the dialog via SetControl. I guess I could have the GetEditWidget also return a center flag, but I feel like there must a way for this to work. I can use it as a last resort though.
I tried myself doing nested sizers, one with EXPAND and one with ALIGN CENTER, and swapping which was which, but I could not get a solution. Either everything would stretch out and the checkbox would be to one side, or everything would be centered but the controls wouldn't stretch. I feel like I need a sizer that is told to grow as big as it, and then put that inside another sizer which centers the control but allows it to get big if it needs to. Maybe this is wrong. If I understand you correctly the checkbox also contains a label, like a StaticText, which it is applying the EXPAND to? That makes sense then and perhaps there is no other solution. It seems like a checkbox would exist without this, though. Perhaps not, oh well.
- Mike
···
-----Original Message-----
From: Robin Dunn [mailto:robin@alldunn.com]
Sent: Thursday, February 08, 2007 2:53 PM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] Re: Sizing flag
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!
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org