我正在关注Kivy 的教程,但无法从 .kv 文件正确加载属性。出于某种原因,我有时可以通过 a 提取 .kv 文件for kv in listdir(kv_path): Builder.load_file(kv_path+kv),但我不能通过简单地将 kv 文件放在同一个根目录中并让它“自行导入”来做到这一点?
例如,当使用文件时:
main.py
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.widget import Widget
class Widgets(Widget):
pass
class SimpleKivy3(App):
def build(self):
return Widgets()
if __name__ == "__main__":
SimpleKivy3().run()
SimpleKivy3.kv
<Button>:
font_size: 40
size: 170,75
color: 0,1,0,1
<Widgets>:
Button:
pos: root.x, root.top - self.height
text: "Kivy"
Button:
pos: 170,0
text: "Tutorials"
我在终端上获得以下输出:
$ python main.py
[INFO ] [Logger ] Record log in /home/nickshu/.kivy/logs/kivy_18-09-12_58.txt
[INFO ] [Kivy ] v1.11.0.dev0, git-038acbf, 20180912
[INFO ] [Python ] v3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)
[GCC 7.2.0]
[INFO ] [Factory ] 195 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO ] [Text ] Provider: sdl2
[INFO ] [Window ] Provider: sdl2(['window_egl_rpi'] ignored)
[INFO ] [GL ] Using the "OpenGL" graphics system
[INFO ] [GL ] Backend used <gl>
[INFO ] [GL ] OpenGL version <b'3.0 Mesa 18.0.5'>
[INFO ] [GL ] OpenGL vendor <b'Intel Open Source Technology Center'>
[INFO ] [GL ] OpenGL renderer <b'Mesa DRI Intel(R) HD Graphics P630 (Kaby Lake GT2) '>
[INFO ] [GL ] OpenGL parsed version: 3, 0
[INFO ] [GL ] Shading version <b'1.30'>
[INFO ] [GL ] Texture max size <16384>
[INFO ] [GL ] Texture max units <32>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[INFO ] [ProbeSysfs ] device match: /dev/input/event6
下面的窗口显示!
有谁知道我做错了什么?这些是我的权限/dev/input/event6
crwxrwxr-- 1 root input 13, 70 Sep 11 23:47 /dev/input/event6
相关分类