Python 3.x KivyMD AttributeError:“非类型”对象没有“主题”属性

Python 3.x KivyMD AttributeError:“非类型”对象没有“主题”属性,python-3.x,kivy,kivy-language,Python 3.x,Kivy,Kivy Language,我很难让KivyMD工作,我已经阅读了很多关于这个错误的问题,但是没有一个有效。下面是一个最低限度的可运行示例,我知道问题在于MyApp类中的代码,但我不知道它为什么不工作。提前谢谢你的帮助 main.py import kivy from kivy.app import App from kivy.properties import ObjectProperty, StringProperty, NumericProperty, ListProperty from kivy.uix.scree

我很难让KivyMD工作,我已经阅读了很多关于这个错误的问题,但是没有一个有效。下面是一个最低限度的可运行示例,我知道问题在于MyApp类中的代码,但我不知道它为什么不工作。提前谢谢你的帮助

main.py

import kivy
from kivy.app import App
from kivy.properties import ObjectProperty, StringProperty, NumericProperty, ListProperty
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.uix.button import Button
from kivy.core.window import Window
from kivymd.theming import ThemeManager
import mysql.connector


Window.clearcolor = (1,1,1,1)


class Information(Screen):
    pass


class WindowManager(ScreenManager):
    pass


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

screens = [Information(name="information")]
for screen in screens:
    sm.add_widget(screen)

sm.current = "information"


class MyApp(App):
    theme_cls = ThemeManager()

    def build(self):
        return sm


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

<Information>:
    name: "information"

    FloatLayout:

        ActionBar:
            pos_hint: {'top': 1}
            ActionView:
                background_image: ""
                background_color: 0.2,0.6,1,1
                ActionPrevious:
                    app_icon: "white menu.png"
                    with_previous: False
                ActionOverflow:
                ActionButton:
                    app_icon: "close.png"
                    on_release: print("Button pressed")

        MDRaisedButton:
            text: "Test"
定义MyApp类后,只需执行Builder.load_文件。您可以将其移动到生成方法中:

 AttributeError: 'NoneType' object has no attribute 'theme_cls'
   File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\kivy\lang\builder.py", line 696, in _apply_rule
     setattr(widget_set, key, value)
   File "kivy\weakproxy.pyx", line 35, in kivy.weakproxy.WeakProxy.__setattr__
   File "kivy\properties.pyx", line 497, in kivy.properties.Property.__set__
   File "kivy\properties.pyx", line 544, in kivy.properties.Property.set
   File "kivy\properties.pyx", line 599, in kivy.properties.Property.dispatch
   File "kivy\_event.pyx", line 1214, in kivy._event.EventObservers.dispatch
   File "kivy\_event.pyx", line 1120, in kivy._event.EventObservers._dispatch
   File "kivy\properties.pyx", line 1318, in kivy.properties.ReferenceListProperty.trigger_change
   File "kivy\properties.pyx", line 1333, in kivy.properties.ReferenceListProperty.trigger_change
   File "kivy\properties.pyx", line 599, in kivy.properties.Property.dispatch
   File "kivy\_event.pyx", line 1214, in kivy._event.EventObservers.dispatch
   File "kivy\_event.pyx", line 1120, in kivy._event.EventObservers._dispatch
   File "C:\Users\user\AppData\Local\Programs\Python\Python37-32\lib\site-packages\kivymd\uix\elevation.py", line 126, in _update_shadow
     self._shadow = App.get_running_app().theme_cls.quad_shadow
class MyApp(App):
    theme_cls = ThemeManager()

    def build(self):
        kv = Builder.load_file("kivy.kv")
        sm = WindowManager()

        screens = [Information(name="information")]
        for screen in screens:
            sm.add_widget(screen)

        sm.current = "information"
        return sm


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