Curious why this alignment has to be set up this way

Hi list,
I'm wondering about box sizers. I have a vertical sizer with a
listCtrl and a horizontal sizer added to it. The horizontal one
contains three buttons. When I add the list and hSizer to my vSizer,
the buttons are all on the left. The thing is, they remain on the left
even when I say,

hSizer.Add(myButton, 0, wx.ALIGN_RIGHT)

for all of them. Only after I change

vSizer.Add(hSizer, 1)

to

vSizer.Add(hSizer, 1, wx.ALIGN_RIGHT)

do the buttons suddenly move to the right where I wanted them. I
thought the buttons would align to the far right in their sizer, but
they don't. Why does aligning the buttons right appear to do nothing,
while aligning the whole hSizer right does the job? To what are the
buttons aligning themselves if not the edge of the sizer? Thanks in
advance!

Alex Hall wrote:

do the buttons suddenly move to the right where I wanted them. I
thought the buttons would align to the far right in their sizer, but
they don't.

Actually, yes, they are. It's just that your horizontal sizer reduced
itself to fit the size of the buttons. The buttons are right-aligned
within the sizer, but the sizer is left-aligned in its container.

I believe you could have achieved the same effect by using wx.EXPAND
when you added the hsizer to the vsizer.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Thanks. I didn't realize that sizers would shrink. I thought that a
horizontal box sizer would always take up as much room, horizontally,
as it could. Were I to give this sizer wx.EXPAND, it would grow
horizontally and vertically when the window is enlarged, but I want to
keep it vertically the same while letting it grow horizontally. Is
that doable?

···

On 2/5/16, Tim Roberts <timr@probo.com> wrote:

Alex Hall wrote:

do the buttons suddenly move to the right where I wanted them. I
thought the buttons would align to the far right in their sizer, but
they don't.

Actually, yes, they are. It's just that your horizontal sizer reduced
itself to fit the size of the buttons. The buttons are right-aligned
within the sizer, but the sizer is left-aligned in its container.

I believe you could have achieved the same effect by using wx.EXPAND
when you added the hsizer to the vsizer.

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

--
You received this message because you are subscribed to the Google Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex Hall wrote:

Thanks. I didn't realize that sizers would shrink. I thought that a
horizontal box sizer would always take up as much room, horizontally,
as it could. Were I to give this sizer wx.EXPAND, it would grow
horizontally and vertically when the window is enlarged, but I want to
keep it vertically the same while letting it grow horizontally. Is
that doable?

I don't think there's anything wrong with the solution you found. Just
pile the buttons in, let the sizer decide how big it should be, and
right-align the sizer.

I suppose you could add a stretchable spacer as the first thing in the hbox.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Yes that is do-able:
Does this help?

http://pastebin.com/nhif09dq