【发布时间】:2014-08-23 01:27:04
【问题描述】:
我一直在尝试用 kivy 构建一些东西,但是每当我尝试在目录中加载不同的东西时,它都会说在目录中找不到该程序,但我确定它在那里。下面是两个程序的代码和错误。程序(main.py 和 pong.kv)都在 Windows(C:) 中的 pong_directory.py 目录中。非常感谢任何反馈。
main.py:
from kivy.app import App
from kivy.uix.widget import Widget
class pongGame(Widget):
pass
class pongApp(App):
def build(self):
return pongGame()
if __name__ == '__main__':
pongApp().run()
pong.kv:
#:kivy 1.8.0
<PongGame>:
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: "0"
Label:
font_size: 70
center_x: root.width * 3 / 4
top: root.top - 50
text: "0"
错误:
[INFO ] Kivy v1.8.0
[INFO ] [Logger ] Record log in C:\Users\rabbitrabbit\.kivy\logs\kivy_14-08-22_21.txt
[INFO ] [Factory ] 157 symbols loaded
[DEBUG ] [Cache ] register <kv.lang> with limit=None, timeout=Nones
[DEBUG ] [Cache ] register <kv.image> with limit=None, timeout=60s
[DEBUG ] [Cache ] register <kv.atlas> with limit=None, timeout=Nones
[INFO ] [Image ] Providers: img_tex, img_dds, img_pygame, img_gif (img_pil ignored)
[DEBUG ] [Cache ] register <kv.texture> with limit=1000, timeout=60s
[DEBUG ] [Cache ] register <kv.shader> with limit=1000, timeout=3600s
[DEBUG ] [App ] Loading kv <C:\pong_directory.py\pong.kv>
[DEBUG ] [App ] kv <C:\pong_directory.py\pong.kv> not found
[DEBUG ] [Window ] Ignored <egl_rpi> (import error)
[INFO ] [Window ] Provider: pygame(['window_egl_rpi'] ignored)
[DEBUG ] [Window ] Display driver windib
[DEBUG ] [Window ] Actual window size: 800x600
[DEBUG ] [Window ] Actual color bits r8 g8 b8 a0
[DEBUG ] [Window ] Actual depth bits: 24
[DEBUG ] [Window ] Actual stencil bits: 8
[DEBUG ] [Window ] Actual multisampling samples: 2
GLEW initialization succeeded
[INFO ] [GL ] OpenGL version <b'2.1.2'>
[INFO ] [GL ] OpenGL vendor <b'NVIDIA Corporation'>
[INFO ] [GL ] OpenGL renderer <b'Quadro NVS 110M/PCI/SSE2'>
[INFO ] [GL ] OpenGL parsed version: 2, 1
[INFO ] [GL ] Shading version <b'1.20 NVIDIA via Cg compiler'>
[INFO ] [GL ] Texture max size <4096>
[INFO ] [GL ] Texture max units <16>
[DEBUG ] [Shader ] Fragment compiled successfully
[DEBUG ] [Shader ] Vertex compiled successfully
[DEBUG ] [ImagePygame ] Load <C:\Python33\lib\site-packages\kivy\data\glsl\default.png>
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[INFO ] [OSC ] using <thread> for socket
[DEBUG ] [Base ] Create provider from mouse
[DEBUG ] [Base ] Create provider from wm_touch
[DEBUG ] [Base ] Create provider from wm_pen
[INFO ] [Base ] Start application main loop
如您所见,当我确定它存在时,它表示它在 pong_directory.py 中找不到 pong.kv。如果有人知道发生了什么,我将不胜感激。
编辑:在尝试了建议的错误后,程序仍然具有相同的最终结果,但在 shell 中出现了一个新错误:
[DEBUG ] [App ] kv <C:\pong_directory\pong.kv> not found
[DEBUG ] [Window ] Ignored <egl_rpi> (import error)
[INFO ] [Window ] Provider: pygame(['window_egl_rpi'] ignored)
[DEBUG ] [Window ] Display driver windib
我不确定这是否是图形问题,但我在 SE(Kivy-python: error while running Hello world) 上发现了一个类似错误的问题,但另一个问题仍然存在。如果有人知道发生了什么反馈,我们将不胜感激。
编辑:在添加 'import kivy' 和 'kivy.require('1.8.0') 行后 pong.kv 仍然被忽略。
【问题讨论】:
-
我不知道怎么了。
print(os.path.exists('C:\pong_directory.py\pong.kv'))如果你写在你的程序里会说什么?如果重命名目录以删除最后的 .py 会发生什么? -
我能看到的唯一一点是你的脚本和我所有的 kivy 脚本不同的是,我总是在我的脚本中包含“import kivy”和“kivy.require('1.8.0')”这行。我还以为你也...?
-
另外,我假设您可能已经检查过您的 kv 文件绝对 100% 保存为 .kv