【发布时间】:2017-06-17 17:18:08
【问题描述】:
我正在用 Python 和 Kivy 构建一个生命计数器。
下面是我的kv代码
#:kivy 1.0
<Test>:
AnchorLayout:
anchor_x: 'center'
anchor_y: 'top'
ScreenManager:
size_hint: 1, .9
id: _screen_manager
Screen:
name: 'screen1'
BoxLayout:
orientation: 'vertical'
padding: 50
BoxLayout:
orientation: 'horizontal'
Button:
text: "Life Counter"
BoxLayout:
orientation: 'horizontal'
Button:
text: "Player 1"
Button:
text: "Player 2"
BoxLayout:
orientation: 'horizontal'
Button:
text: "-"
Button:
text: "0"
Button:
text: "+"
Button:
text: "-"
Button:
text: "0"
Button:
text: "+"
这是我的应用程序
import kivy
kivy.require('1.0.7')
from kivy.app import App
class TestApp(App):
pass
if __name__ == '__main__':
TestApp().run()
这是我的输出
你能帮我理解我缺少什么吗? 如果我在 kv 文件中添加一个带有描述的简单按钮,则代码可以完美运行。 谢谢
【问题讨论】:
-
删除 .kv 中的
<Test>:行并重新缩进。 -
它有效.. 谢谢!