I got a problem with my kv code here. I want to create a MDNavigationDrawer
with a few NavigationDrawerIconButtons
. The window shows up but when I clic
left_action_items: [['dots-vertical', lambda x: root.toggle_nav_drawer()]]
File "kivy\weakproxy.pyx", line 32, in kivy.weakproxy.WeakProxy.__getattr__
AttributeError: 'LayoutPy' object has no attribute 'toggle_nav_drawer'
The object, LayoutPy
does not has an attribute toggle_nav_drawer
because the toggle_nav_drawer
is defined in the instantiated child, NavigationLayout:
of LayoutPy
.
Replace root.toggle_nav_drawer()
with root.ids.nav_layout.toggle_nav_drawer()
BoxLayout:
orientation: 'vertical'
MDToolbar:
id: toolbar
title: 'Menu'
md_bg_color: app.theme_cls.primary_color
background_palette: 'Primary'
background_hue: '500'
left_action_items: [['dots-vertical', lambda x: root.ids.nav_layout.toggle_nav_drawer()]]