我不熟悉Python中的gui,想试试Kivy。 但在乒乓球教程中,我被卡住了: 我运行原始脚本并得到以下错误:
[WARNING ] [Lang ] The file C:\Users\Canopy\Skripts\Pong\pong.kv is loaded multiples times, you might have unwanted behaviors.
[INFO ] [Base ] Start application main loop
[ERROR ] [Base ] No event listeners have been created
[ERROR ] [Base ] Application will leave
为什么这些列表器丢失,为什么其他人(显然)可以运行代码?在
EDIT: A restart fixed it for once, but the next time I run the application I run into the same problem. The .kv doesn't seem to be properly closed.
我在win7上运行python2.7(canopy) 以下是脚本: 主.py公司名称:
^{pr2}$以及乒乓球公司名称:
#:kivy 1.9.1
<PongBall>:
size: 50, 50
canvas:
Ellipse:
pos: self.pos
size: self.size
<PongPaddle>:
size: 25, 200
canvas:
Rectangle:
pos:self.pos
size:self.size
<PongGame>:
ball: pong_ball
player1: player_left
player2: player_right
canvas:
Rectangle:
pos: self.center_x-5, 0
size: 10, self.height
Label:
font_size: 70
center_x: root.width / 4
top: root.top - 50
text: str(root.player1.score)
Label:
font_size: 70
center_x: root.width * 3 / 4
top: root.top - 50
text: str(root.player2.score)
PongBall:
id: pong_ball
center: self.parent.center
PongPaddle:
id: player_left
x: root.x
center_y: root.center_y
PongPaddle:
id: player_right
x: root.width-self.width
center_y: root.center_y
好吧,基本的IT解决方案实际上起到了作用: 重新启动电脑后,错误不再发生。 编辑:再次运行应用程序后,我遇到了相同的问题。还需要解决方案!在
相关问题 更多 >
编程相关推荐