python - kivy中的网格布局格式
问题描述
我目前正在 kivy 开发一个应用程序。我对网格布局和按钮有疑问。这就是我的按钮和图片现在的样子https://i.stack.imgur.com/JrbkL.png。当你看到图片时,你会看到一个播放按钮,在播放按钮旁边我想再添加两张图片。谁能帮忙
这是我的图片代码
GridLayout:
rows: 3
size_hint: 1, 1
pos_hint: {"top": 1, "right": 1}
Button:
size_hint: 1, .4
pos_hint: {"top": .4, "right": 1}
text: "This is player 1"
ImageButton:
size_hint: 1, .2
pos_hint: {"top": .2, "right": 1}
source: "play.png"
Button:
size_hint: 1, .4
pos_hint: {"top": .4, "right": 1}
text: "This the second player"
解决方案
您可以尝试在第二行插入另一个 3 列的 GridLayout,如下所示:
GridLayout:
rows: 3
size_hint: 1, 1
pos_hint: {"top": 1, "right": 1}
Button:
size_hint: 1, .4
pos_hint: {"top": .4, "right": 1}
text: "This is player 1"
GridLayout:
cols: 3
ImageButton:
size_hint: 1, .2
pos_hint: {"top": .2, "right": 1}
source: "play.png"
ImageButton:
size_hint: 1, .2
pos_hint: {"top": .2, "right": 1}
source: "play.png"
ImageButton:
size_hint: 1, .2
pos_hint: {"top": .2, "right": 1}
source: "play.png"
Button:
size_hint: 1, .4
pos_hint: {"top": .4, "right": 1}
text: "This the second player"
推荐阅读
- javascript - 您如何在外部 Javascript 中引用 html 元素?
- laravel-5.8 - 像json一样保存时如何返回等级表的名称?
- python - 如何使用 Numpy 在 Python 中创建 3D 数组?
- android - 使 recyclerview 项目占用屏幕宽度并将其定位在点击
- python - 使用mysql连接器python将值插入数据库,网络抓取
- c# - C# - 我可以在运行时设置泛型参数的类型来整理以下代码吗?
- html - 当我在锚元素中使用 #elemend_id 作为 href 时,有没有办法将注意力集中在目标元素上?
- javascript - 尝试执行单独的 PHP 查询时 AJAX 返回当前页面
- docker - Docker Hub 私有存储库:无法在私有存储库中推送 Solr Core 文件
- python - 使用 pandas 从 xml url 读取单个节点