On Nov 20, 2010, at 4:54 AM, Fraser Burns wrote:

> Then I found Ed's "How to visually Float a Control..."
> It agrees with what I thought I was doing. But it doesn't succeed either.
> What am I missing?
> 
> class MainForm(dabo.ui.dForm):
>    def afterInit(self):
>        lbl = dabo.ui.dLabel(self, Caption="I'm meant to be in the 
> middle !")
>        sz = dabo.ui.dSizer("h")
>        sz.appendSpacer(1, proportion=1)
>        sz.append(lbl, proportion=0)
>        sz.appendSpacer(1, proportion=1)
>        self.Sizer.append(sz)
>        self.layout()
> 
> At this stage I have left off the "expand", and valign="middle" to try 
> to keep it simple.
> The label appears in the top left corner of my window.

        When you are appending the horizontal sizer ('sz') to the form's sizer, 
you aren't telling the form's sizer to expand 'sz' to the form's full width, so 
sz is taking up the minimal amount of space it requires. You could change this 
call in one of two ways:

self.Sizer.append(sz, halign="center")
        -or-
self.Sizer.append(sz, "x")

        Either of these will work, but the latter approach uses the spacers, 
while the former leaves them at 1px and then centers the results, while the 
latter expands the area given to 'sz'. Turning on the 'Show Sizer Lines' option 
makes this a little clearer; I've included some screenshots of both approaches. 
I've added a yellow BackColor to the label to make its size more apparent.

Using halign="center": http://leafe.com/tmp/halign.png
Using expand: http://leafe.com/tmp/expand.png


-- Ed Leafe



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to