Q:

как открыть MDNavigationDrawer?

есть 3 вкладки с переходами , после возвращения назад я пытаюсь открыть  MDNavigationDrawer и у меня вылетает ошибка:
File "C:\Users\Апостол Моисей\Desktop\programing\tk\tet\yyy2.py", line 106, in 
     self.root.ids.toolbar.left_action_items = [["menu", lambda x: nav_drawer.toggle_nav_drawer()]]
 NameError: name 'nav_drawer' is not defined
вот мой код:
from kivy.uix.boxlayout import BoxLayout

from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.properties import ObjectProperty

KV = '''

<ContentNavigationDrawer>:
    orientation: "vertical"
    padding: "8dp"
    spacing: "8dp"

    ScrollView:

        MDList:

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

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

Screen:

    NavigationLayout:

        ScreenManager:
            id: screen_manager

            Screen:
                name: "screen 1"

                BoxLayout:
                    orientation: 'vertical'

                    MDToolbar:
                        id: toolbar
                        title: "Navigation Drawer"
                        elevation: 10
                        left_action_items: [['menu', lambda x: nav_drawer.toggle_nav_drawer()]]

                    Carousel:
                        id: carousel
                        on_current_slide: app.on_current_slide(*args)

                        Screen:

                            MDFlatButton: 
                                text: 'Screen 1' 
                                on_release: carousel.load_next()
                                pos_hint: {"center_x": .5, "center_y": .5}

                        Screen:
                            name: "screen 2"

                            MDFlatButton: 
                                text: 'Screen 2'
                                on_release: carousel.load_next()
                                pos_hint: {"center_x": .5, "center_y": .5}

                        Screen:
                            name: "screen 3"

                            MDFlatButton: 
                                text: 'Screen 3' 
                                on_release: carousel.load_next()
                                pos_hint: {"center_x": .5, "center_y": .5}

        MDNavigationDrawer:
            id: nav_drawer

            ContentNavigationDrawer:
                screen_manager: screen_manager
                nav_drawer: nav_drawer
'''

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

    def on_current_slide(self, instance_carousel, instance_screen):

        if instance_screen.name == "screen 2":
            self.root.ids.toolbar.left_action_items = [["arrow-left", lambda x: self.set_previous_screen()]]
        else:
            self.set_toolbar_button()

        if instance_screen.name == "screen 3":
            self.root.ids.toolbar.left_action_items = [["arrow-left", lambda x: self.set_previous_screen()]]

    def set_toolbar_button(self):
        self.root.ids.toolbar.left_action_items = [["menu", lambda x: nav_drawer.toggle_nav_drawer()]]

    def set_previous_screen(self):  #установить предыдущий экран
        self.root.ids.carousel.load_previous()
        self.set_toolbar_button()

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

TestNavigationDrawer().run()

A:

def set_toolbar_button(self):
    self.root.ids.toolbar.left_action_items = [["menu", lambda x: self.root.ids.nav_drawer.toggle_nav_drawer()]]

