Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NavigationLayout Kivy err0r

I decided to update kivy. Previously, there was no such error, now:

raise FactoryException('Unknown class <%s>' % name)
 kivy.factory.FactoryException: Unknown class <NavigationLayout>

Code:

from kivy.lang import Builder
from kivymd.app import MDApp
from kivy.core.window import Window
Window.size = (600,550)
KV = '''
Screen:
    NavigationLayout:
        MDNavigationDrawer:
            id: draver
            BoxLayout:
                orientation: 'vertical'
                ScrollView:
                    MDList:
                        BoxLayout:
                            id: box 
                        OneLineIconListItem:
                            on_press: app.star()
                            text: 'Избранное'
                            IconLeftWidget:
                                icon: 'star'
                        OneLineIconListItem:
                            text: 'Настройки'
                            IconLeftWidget:
                                icon: 'settings'    
'''
class Test(MDApp):
    def build(self):
        return Builder.load_string(KV)
    
Test().run()

Please helppp

this is written because the site does not allow you to ask a question this is written because the site does not allow you to ask a question this is written because the site does not allow you to ask a question this is written because the site does not allow you to ask a question

like image 742
Mirai Avatar asked Oct 31 '25 16:10

Mirai


2 Answers

You have to choose kivy or kivymdfor theses widgets: NavigationLayout MDNavigationDrawer.

Actually, you are melting the two libraries and they don't like it. Use:

  • MDNavigationLayout and MDNavigationDrawer
  • OR NavigationLayout and NavigationDrawer
like image 69
Utopion Avatar answered Nov 03 '25 05:11

Utopion


Using MDNavigationDrawer has changed! You should now use this markup structure:

Root:

    MDNavigationLayout:

        ScreenManager:

            ...
            ...

        MDNavigationDrawer:

            UserContentNavigationDrawer:

MDNavigationDrawer is an empty MDCard class into which you add your own content.

i.e in summary change the NavigationLayout to MDNavigationLayout.

See this github page for more info:

https://github.com/kivymd/KivyMD/wiki/Components-Navigation-Drawer#using-mdnavigationdrawer-has-changed

I wonder why the official site hasn't been change, this update is about a year now!

like image 29
Edwin Avatar answered Nov 03 '25 07:11

Edwin