简体   繁体   中英

KivyMD Error: ValueError: KivyMD: App object must be initialized before loading root widget

How do I fix this error:

ValueError: KivyMD: App object must be initialized before loading root widget.

My Code:

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

class MyMainApp(MDApp):

    def __init__(self, **kwargs): 
        App.__init__(self)   
        theme_cls = ThemeManager()


if __name__ == "__main__":
    MyMainApp().run()

Everything online says that I have to move my .kv file inside my .py file. Is there a way to keep my .kv file?

https://kivymd.readthedocs.io/en/latest/themes/material-app/#kivymd.app.MDApp.theme_cls

class MainApp(MDApp):
    def build(self):
        self.theme_cls.primary_palette = "Teal"

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM