Where is there a current navigationdrawer change screens example?

300 views
Skip to first unread message

Dean-O Rochester

unread,
Jun 29, 2021, 6:26:17 PM6/29/21
to kivy-...@googlegroups.com
Hi all
Looking for how to use a navigation drawer with items in the list that when you select one it changes the screenmanager screen

I have found a couple but they are dated and the navigationdrawer has changeD it’s behavior and the wiki and docs aren’t current either

Thanks in advance for your time

Dean-O

Sent from my Droid-iPodPad-Berry

Dean-O

Sent from my Droid-iPodPad-Berry

Elliot Garbus

unread,
Jun 29, 2021, 10:26:10 PM6/29/21
to kivy-...@googlegroups.com

Here is the example for the docs.  It is working for me.

I am running kivymd version 1.0.0.dev0

 

from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import ObjectProperty

from kivymd.app import MDApp

KV =
'''
<ContentNavigationDrawer>:

    ScrollView:

        MDList:

            OneLineListItem:
                text: "Screen 1"
                on_press:
                    root.nav_drawer.set_state("close")
                    root.screen_manager.current = "scr 1"

            OneLineListItem:
                text: "Screen 2"
                on_press:
                    root.nav_drawer.set_state("close")
                    root.screen_manager.current = "scr 2"


Screen:

    MDToolbar:
        id: toolbar
        pos_hint: {"top": 1}
        elevation: 10
        title: "MDNavigationDrawer"
        left_action_items: [["menu", lambda x: nav_drawer.set_state("open")]]

    MDNavigationLayout:
        x: toolbar.height

        ScreenManager:
            id: screen_manager

            Screen:
                name: "scr 1"

                MDLabel:
                    text: "Screen 1"
                    halign: "center"

            Screen:
                name: "scr 2"

                MDLabel:
                    text: "Screen 2"
                    halign: "center"

        MDNavigationDrawer:
            id: nav_drawer

            ContentNavigationDrawer:
                screen_manager: screen_manager
                nav_drawer: nav_drawer
'''


class ContentNavigationDrawer(BoxLayout):
    screen_manager = ObjectProperty()
    nav_drawer = ObjectProperty()


class TestNavigationDrawer(MDApp):
   
def build(self):
       
return Builder.load_string(KV)


TestNavigationDrawer().run()

--

You received this message because you are subscribed to the Google Groups "Kivy users support" group.

To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/73E5C735-0D5C-43BF-A5B6-C985EA5F2D0F%40gmail.com.

 

Dean-O Rochester

unread,
Jul 6, 2021, 4:14:45 PM7/6/21
to Kivy users support
HI 
I am using kivy 2.0   

when I try this I get an error it will not run

/kivy/factory.py", line 146, in __getattr__

     raise FactoryException('Unknown class <%s>' % name)

 kivy.factory.FactoryException: Unknown class <MDNavigationLayout>



So I ask again, is there a working example of a navigationdrawer change screens example?

Thanks in advance
Dean-O

Ryan Anderson

unread,
Jul 6, 2021, 4:33:30 PM7/6/21
to Kivy users support
I think that's the error you get when you try to use MD Widgets in a Kivy (instead of KivyMD) app. You might check to be sure your app class derives from kivymd.app.MDApp, rather than kivy.app.App.

Elliot Garbus

unread,
Jul 6, 2021, 4:33:55 PM7/6/21
to kivy-...@googlegroups.com

Have you installed kivymd?

See: https://kivymd.readthedocs.io/en/latest/getting-started/#getting-started

Install kivymd into the same venv you installed kivy.

rocki...@gmail.com

unread,
Jul 6, 2021, 6:29:54 PM7/6/21
to kivy-...@googlegroups.com
here is my pip list for my virtual env I am using

Package                   Version

------------------------- ---------

altgraph                  0.17

certifi                   2020.12.5

chardet                   4.0.0

Cython                    0.29.23

docutils                  0.17.1

idna                      2.10

importlib-metadata        4.0.1

Kivy                      2.0.0

Kivy-Garden               0.1.4

kivymd                    0.104.1

macholib                  1.14

Pillow                    8.2.0

pip                       21.1.2

Pygments                  2.9.0

pyinstaller               4.3

pyinstaller-hooks-contrib 2021.1

requests                  2.25.1

setuptools                39.0.1

typing-extensions         3.10.0.0

urllib3                   1.26.4

zipp                      3.4.1



So yes I have Kivymd installed.

Other options?

--
You received this message because you are subscribed to a topic in the Google Groups "Kivy users support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/kivy-users/13qsDGixBu8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to kivy-users+...@googlegroups.com.

To view this discussion on the web visit

Elliot Garbus

unread,
Jul 6, 2021, 6:39:39 PM7/6/21
to kivy-...@googlegroups.com

Dean-O Rochester

unread,
Jul 6, 2021, 6:53:53 PM7/6/21
to Kivy users support
Bingo!!!!!  

Thanks so much   Off to the races now :)

Reply all
Reply to author
Forward
0 new messages