def update(self, title=None, items=None): if title is not None: self.info = {'title':title} if items is not None: menu = self.widgets['menu'] menu.remove_all() for item in items: if isinstance(item, MenuItemModel): menu.add(item) else: text, handler, arg = item menu_item = MenuItemModel(text) menu_item.handler = handler menu_item.arg = arg menu_item.signals['pressed'].connect(self._handle_pressed) menu.add(menu_item)
def __init__(self, title, items, skin='menu'): menu = MenuModel() for item in items: if isinstance(item, MenuItemModel): menu.add(item) else: text, handler, arg = item menu_item = MenuItemModel(text) menu_item.handler = handler menu_item.arg = arg menu_item.signals['pressed'].connect(self._handle_pressed) menu.add(menu_item) super(MenuDialog, self).__init__(skin, {'menu':menu}, {'title':title}) menu.set_active(True) self.menu = menu self.exit_hides_dialog = True