Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

BoxLayout doesn't honor pos_hint #698

Closed
Titousensei opened this Issue · 8 comments

5 participants

@Titousensei

BoxLayout honrs size_hint, allowing, for instance, a button to be 50% the width of the container box (if orientation = vertical). But the button will always be aligned to the left, since neither pos_hint nor pos seem to have any effect.

It would make sens to apply pos_hint whenever size_hint is possible in a Layout.

(A workaround to put a Layout inside the Layout to get the same effect, but that complicates the tree unncessarily.)

@akshayaurora
@Titousensei

I see. The dummy Widget solution only allows for absolute positioning, though, and it's not possible to center the button. I find that a very ugly solution and I prefer wrapping my button in a FloatLayout. (Which is the workaround I suggested.)

However, I would argue that BoxLayout only controls one dimension of the positioning of its children: the dimension defined by the orientation. The positioning on the other dimension is not defined in BoxLayout, and indeed arbitrary. So it would make sens to allow the user to specify the positioning only for the other dimension, by borrowing existing mechanisms of FloatLayout: pos and pos_hint.

@tshirtman
Owner
@hansent
@Titousensei

My use case is the following:

BoxLayout "vertical"
Slider
Button
Progressbar

The slider and progressbar can be 100% width, but I want the button to be smaller (50% width with size_hint), and centered.

My issue is that it seems completely arbitrary to have the widgets aligned to the left by default, and no simple way to change this hard-coded behavior.

The only solution I can find is putting a FloatLayout around the button. This is acceptable in the simple case above, but it can become ugly very fast if you have more than a few widgets you want to custom-align.

(Another option I thought about was to add the property valign or halign to the BoxLayout, but it seems less consistent with the overall design of Kivy.)

@hansent
@tito
Owner

Yep, i think using pos_hint in BoxLayout for inner aligment would be ok.

@tito tito was assigned
@tito
Owner

Ok, doing it.

@tito tito closed this in cfb118c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.