Kivy Layout高度,以适应子小部件的高度 [英] Kivy Layout height to adapt to child widgets's height

查看:72
本文介绍了Kivy Layout高度,以适应子小部件的高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个布局,使其中具有类似于BoxLayout的功能,以便可以在布局中创建行",并且在每个行"中,我都希望使用其他BoxLayout形式的内容来创建列".

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".

列不必均匀分布.例如,我想创建一个BoxLayout,其中一列带有正方形图像,另一列占据可用宽度的其余部分.

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.

在我的要旨上查看代码和屏幕截图: https://gist.github.com/MichaelGradek/e5c50038b947352d9e79

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

我已经在上面的代码中完成了基本结构,但是,另外,我希望BoxLayout的高度能够适应孩子的身高.

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?

谢谢!

推荐答案

不要使用BoxLayout,请使用带有height: self.minimum_height的GridLayout,并为每个子控件设置手动大小(size_hint_y: Noneheight: some_number)

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.

这篇关于Kivy Layout高度,以适应子小部件的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆