Kivy Layout height to adapt to child widgets#39;s height(Kivy 布局高度以适应子小部件的高度)
问题描述
我想创建一个布局,其中我有类似于 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.
在我的 gist 上查看代码和屏幕截图: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: None 和 height: 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 布局高度以适应子小部件的高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Kivy 布局高度以适应子小部件的高度
基础教程推荐
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- 求两个直方图的卷积 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- 修改列表中的数据帧不起作用 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- 包装空间模型 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
