我想创建一个布局,其中我有一些类似于BoxLayout的东西,让我能够在我的布局中创建“行”,在每个“行”中,我想使用另一个BoxLayout中的某种东西来创建“列”。在
这些列不需要均匀分布。例如,我想创建一个BoxLayout,其中一列具有正方形图像,另一列占据剩余的可用宽度。在
请参阅我的要点上的代码和屏幕截图:https://gist.github.com/MichaelGradek/e5c50038b947352d9e79
我已经在上面的代码中完成了基本结构,但除此之外,我希望BoxLayout的高度适应孩子们的身高。
实现这一目标的最佳方法是什么?在
谢谢!在
这里有一些技巧,我已经想出了根据子级高度设置
GridLayout
高度的技巧,但是,这两种方法都要求每行有一个子级。。。因此,制作列确实需要添加内部网格布局。在以上内容可以通过Python代码或静态的
^{pr2}$kv
条目添加,并且在我的项目中,至少可以通过调整包含的子小部件中的每一行的大小来实现。在为了完整起见,举个例子来说明如何将它们缝合在一起。。。在
更新
^{}
上面是我发布的一个项目,它是从一个更大的项目中提取出来的,可能适合也可能不适合那些希望在Python方面有更多逻辑来更新维度的人。查看
ReadMe
文件,以获取有关在另一个项目中安装的提示。在不要使用BoxLayout,使用带有})。在
height: self.minimum_height
的GridLayout,并为每个子小部件设置手动大小(size_hint_y: None
和{相关问题 更多 >
编程相关推荐