Kivy.factory.FactoryException:未知类,但我没有使用该类

时间:2019-09-23 21:40:08

标签: python python-3.x pycharm kivy

在尝试运行程序时出现错误消息,提示未知类<CreateAccountWindow>,但在任何代码中都没有提及CreateAccountWindow。我正在Pycharm中进行一个新项目,而我的旧项目中有一个名为CreateAccountWindow的类。....我认为这一定是原因,但我不知道如何解决。

import kivy
from kivy.app import App
from kivy.properties import ObjectProperty, StringProperty
from kivy.uix.screenmanager import ScreenManager, Screen
from kivy.lang import Builder
from kivy.uix.popup import Popup
from kivy.uix.label import Label
from kivy.core.window import Window

class LoginWindow(Screen):
    pass

class WindowManager(ScreenManager):
    pass

kv = Builder.load_file("my.kv")
sm = WindowManager()

screens = [LoginWindow(name="login")]
for screen in screens:
    sm.add_widget(screen)

sm.current = "login"


class MyApp(App):

    def build(self):
        return sm


if __name__ == '__main__':
    MyApp().run()

kv文件:

WindowManager:
    LoginWindow:

<LoginWindow>:
Traceback (most recent call last):
   File "C:/Users/callu/OneDrive/Documents/TestApp/main.py", line 16, in <module>
     kv = Builder.load_file("my.kv")
   File "C:\Users\callu\AppData\Local\Programs\Python\Python37-32\lib\site-packages\kivy\lang\builder.py", line 301, in load_file
     return self.load_string(data, **kwargs)
   File "C:\Users\callu\AppData\Local\Programs\Python\Python37-32\lib\site-packages\kivy\lang\builder.py", line 405, in load_string
     rule_children=rule_children)
   File "C:\Users\callu\AppData\Local\Programs\Python\Python37-32\lib\site-packages\kivy\lang\builder.py", line 616, in _apply_rule
     cls = Factory_get(cname)
   File "C:\Users\callu\AppData\Local\Programs\Python\Python37-32\lib\site-packages\kivy\factory.py", line 131, in __getattr__
     raise FactoryException('Unknown class <%s>' % name)
 kivy.factory.FactoryException: Unknown class <CreateAccountWindow>

0 个答案:

没有答案