KivyMD: DropdownMenu callback stopped working

Description of the Bug

The DropdownMenu callback is not invoked. This worked before the latest MDMenu changes.

Code and Logs

Below is the example from the docs, modified with adding a callback https://kivymd.readthedocs.io/en/latest/components/menu/index.html#usage

The text “======selected======” does not appear in the console


from kivy.lang import Builder

from kivymd.app import MDApp
from kivymd.uix.menu import MDDropdownMenu

KV = '''
Screen:

    MDRaisedButton:
        id: button
        text: "PRESS ME"
        pos_hint: {"center_x": .5, "center_y": .5}
        on_release: app.menu.open()
'''


class Test(MDApp):
    def selected(self):
        print("=====selected=======")
    
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.screen = Builder.load_string(KV)
        menu_items = [{"icon": "git",
                       "text": f"Item {i}",
                       "callback": self.selected} for i in range(5)]
        self.menu = MDDropdownMenu(
            caller=self.screen.ids.button, items=menu_items, width_mult=4
        )

    def build(self):
        return self.screen


Test().run()

### Screenshots

Add images to explain us this bug. Paste urls here.

Remove this section if no images here


### Versions

* OS:  Windows 10
* Python:  Python 3.6.1
* Kivy:   1.11.1
* KivyMD:   master 4/24/2020

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (6 by maintainers)

Most upvoted comments

@HeaTTheatR I am using kivymd library still not working