python - 哇,改变缩进破坏了我的程序?
问题描述
我的小 Python 和 Kivy 脚本正在运行。然后一个小灯泡弹出了一个选项来调整样式,这似乎是个好主意,所以我做了。然后,除非我在 .kv 文件中将缩进空间更改为 3 的倍数而不是 4,否则它不会运行。我这样做了,突然间,我使用框布局创建的窗口要宽得多,并且所有按钮,图像和标签位于左下角,而之前它们与标签、图像和按钮堆叠在一起,垂直填充窗口。我会尝试将缩进空格撤消为 3s,但它会在任何没有这样间隔的行上引发错误。这是基维代码。我没有更改 python 代码或空格。我知道这听起来很奇怪,但是...
<Pat_layout>:
BoxLayout:
orientation: "vertical"
size: root.width, root.height
Label:
id: name_label
text: "Get ready for exercises"
size_hint: (1, .5)
font_size: 32
multiline: True
Image:
id: image_window
size_hint: (1, .5)
source: 'images/dim_1-4.jpg'
Button:
size_hint: (1, .5)
font_size: 32
text: "Next Exercise"
on_press: root.press()
解决方案
谢谢大家。这确实是我的缩进。当下面的 4 行图像部分被纠正为四个空格缩进时,它停止在左下角放置东西,并且很好地将我的标签、图像和按钮垂直堆叠并占据了整个宽度。
谢谢各位。。。。
吉姆
<Pat_layout>:
BoxLayout:
orientation: "vertical"
size: root.width, root.height
Label:
id: name_label
text: "Exercises Appear Here"
font_size: 32
Image:
id: image_window
size_hint: (1, .5)
source: 'images/dim_1-4.jpg'
Button:
size_hint: (1, .5)
font_size: 32
text: "Press For Next Exercise"
on_press: root.press()
推荐阅读
- vb.net - 在 VB.NET 中引用 SQL 行的 ID 以更新 datagridview 上的选定行
- python - 如何计算来自不同列的两个字符串之间的归一化编辑相似度
- ios - CAShapeLayer 路径未显示
- java - 在“reader = new PdfReader(new RandomAccessFileOrArray(filenameSource),null)”之前添加“Document.plainRandomAccess=true”的原因是什么?
- javascript - 考虑到您无法修改其前端以影响您发送的电子邮件,雅虎如何处理输入?
- python - 如何从图像(使用 Python 或与自动化兼容的网站)中读取数字(从特定位置)?
- css - 使用 Bootstrap 在小屏幕上隐藏图像
- angular - 我们可以将用于单元测试的样本输入数据放在角度
- javascript - 如何将隐藏的 html 元素的值传递给 jQuery?
- python - 使用 csv 在 python 中进行计算