【问题标题】:KivyMD: AttributeError: 'NoneType' object has no attribute 'theme_cls'KivyMD:AttributeError:“NoneType”对象没有属性“theme_cls”
【发布时间】:2017-11-01 14:47:06
【问题描述】:

我现在正在使用 KivyMD。

调用python代码时出现如下错误。

我不知道为什么会出现这样的错误。

请告诉我如何解决它。

Here is image code

【问题讨论】:

    标签: python kivy kivy-language


    【解决方案1】:

    您应该像这样在您的应用程序类中声明theme_cls 实例:

    (.py) 文件

    from kivymd.theming import ThemeManager
    from kivy.app import App
    
    class MyApp(App):
        theme_cls = ThemeManager()
    
        def build(self):
            return MyWidget()
    
    app = MyApp()
    app.run()
    

    (.kv) 文件

    NavigationLayout:
        MDNavigationDrawer:
            #drawer_logo: "/user.jpg"
        Button:
            text: "i'm happy, what about you !"
    

    检查这个:Kivymd Gitlab | Script 1

    所有 kivymd 小部件都继承自 ThemableBehavior 类 - Kivymd Gitlab | Script 2

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-12
      • 1970-01-01
      • 1970-01-01
      • 2021-11-02
      • 2014-07-05
      相关资源
      最近更新 更多