我正在使用python和kivy开发Android应用程序 我正在使用boxlayout并尝试加载布局与字符串,但它没有加载并给我这个错误,并在我运行此代码时打开一个黑色的窗口 我不明白现在是什么问题我得到这个错误请帮助解决这个问题
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
from kivy.uix.label import Label
Builder.load_string('''
<Layout>:
Lebel:
text: "Hello World"
''')
class Layout(BoxLayout):
pass
class MyApp(App):
def build(self):
return Layout()
MyApp().run()
这是错误
Traceback (most recent call last):
File "/root/Desktop/MyApp/main.py", line 25, in <module>
MyApp().run()
File "/usr/lib/python2.7/dist-packages/kivy/app.py", line 802, in run
root = self.build()
File "/root/Desktop/MyApp/main.py", line 23, in build
return Layout()
File "/usr/lib/python2.7/dist-packages/kivy/uix/boxlayout.py", line 102, in __init__
super(BoxLayout, self).__init__(**kwargs)
File "/usr/lib/python2.7/dist-packages/kivy/uix/layout.py", line 72, in __init__
super(Layout, self).__init__(**kwargs)
File "/usr/lib/python2.7/dist-packages/kivy/uix/widget.py", line 320, in __init__
Builder.apply(self, ignored_consts=self._kwargs_applied_init)
File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 1970, in apply
self._apply_rule(widget, rule, rule, ignored_consts=ignored_consts)
File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 2044, in _apply_rule
cls = Factory_get(cname)
File "/usr/lib/python2.7/dist-packages/kivy/factory.py", line 131, in __getattr__
raise FactoryException('Unknown class <%s>' % name)
kivy.factory.FactoryException: Unknown class <Lebel>
[Finished in 0.6s with exit code 1]
[shell_cmd: python -u "/root/Desktop/MyApp/main.py"]
[dir: /root/Desktop/MyApp]
[path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin]
答案 0 :(得分:2)
kivy.factory.FactoryException:未知类
你拼错了标签。