I'm new on kivy/kivymd and I am trying to create a dropdown menu through the kivymd documentation. However, whenever I click on the dropdown it returns this error to me:
AttributeError: 'Box_2' object has no attribute 'menu'
I'm not sure what have i done wrong, so any help is welcome.
this is my .py file: (as it appears in the documentation)
class Box_2(GridLayout):
def set_item(self, instance_menu, instance_menu_item):
menu_items = [{"icon": "git", "text": f"Item {i}"} for i in range(5)]
self.menu = MDDropdownMenu(
caller=self.Box_2.ids.drop_item,
items=menu_items,
position="center",
width_mult=4,
)
self.menu.bind(on_release=self.set_item)
self.Box_2.ids.drop_item.set_item(instance_menu_item.text)
self.menu.dismiss()
and this is my .kv file:
<Box_2>:
MDDropDownItem:
id: drop_item
text: 'Projeto'
on_release: root.menu.open()