我想使用DropDown进行下一次使用的选择功能。在我的代码中,它意味着:
但函数DropDownButton.on_create_folder()未被事件激活。我的代码中的问题怎么样?
Builder.load_string('''
<FolderDropDownMenu>:
Button:
text: 'Create'
on_release: root.on_create('inst', 'val')
Button:
text: 'Remove'
on_release: root.on_remove('inst', 'val')
''')
# dropdown menu
class DropDownMenu(DropDown):
def __init__(self, **kwargs):
super(FolderDropDownMenu, self).__init__(**kwargs)
self.register_event_type('on_create_folder')
def on_create_folder(self):
pass
def on_create(self, inst, val):
self.dispatch('on_create_folder')
return
# main button
class DropDownButton(BoxLayout):
def __init__(self, **kwarg):
super(FolderDropDownButton, self).__init__(**kwarg)
self.dropdown = FolderDropDownMenu()
self.dropdown.bind(on_create_folder = lambda *largs: self.on_create_folder)
. . .
. . .
return
def on_create_folder(self, inst, val):
. . .
. . .
return