Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kivy Layout height to adapt to child widgets's height

I want to create a layout where I have something similar to a BoxLayout to give me the ability to create "rows" in my layout, and in each "row" I want to use something in the sorts of another BoxLayout to create "columns".

The columns don't need to be evenly distributed. For example, I want to create a BoxLayout with one column with a square image, and another occupying the rest of the available width.

See code and screenshot on my gist: https://gist.github.com/MichaelGradek/e5c50038b947352d9e79

I have the basic structure done in the code above, but in addition, I want the BoxLayout's height to adapt to the height of the children.

What would be the best approach to achieve this?

Thanks!

like image 929
Michael Gradek Avatar asked Sep 11 '15 08:09

Michael Gradek


2 Answers

Don't use a BoxLayout, use a GridLayout with height: self.minimum_height, and set a manual size (size_hint_y: None and height: some_number) for each child widget.

like image 152
inclement Avatar answered Sep 22 '22 17:09

inclement


For me, using a GridLayout with height: self.minimum_height, and then setting a manual size (size_hint_y: None and height: some_number) for each child widget, resulted in widgets getting anchored to the bottom of root window. Couldn't really figure out why?

However, using a GridLayout with height: root.height, and then setting a manual size (size_hint_y: None and height: some_number) for each child widget resulted in correct top anchored widgets.

like image 32
ahlwhl Avatar answered Sep 22 '22 17:09

ahlwhl