4

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

Mirai
  • 115
  • 2
  • 16

3 Answers3

3

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
Utopion
  • 935
  • 1
  • 4
  • 15
2

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!

Edwin
  • 565
  • 11
  • 26
0

Ran the exact program you posted. No error. Although no Navigation bar too, that's just the code is incomplete. Use official KivyMD website for the correct format.

https://kivymd.readthedocs.io/en/latest/components/navigation-drawer/

Try creating a new Virtual env and run it there.

Alex_C
  • 71
  • 1