core, frontends: callMenu is now async and don't use callback_id anymore
This commit is contained in:
parent
5723ee2ef2
commit
71c1def32a
1 changed files with 93 additions and 56 deletions
|
|
@ -115,6 +115,17 @@ class MainWindow(wx.Frame, QuickApp):
|
|||
self.menuBar.EnableTop(i, True)
|
||||
super(MainWindow, self).plug_profile(profile_key)
|
||||
|
||||
def _dynamicMenuCb(self, xmlui):
|
||||
XMLUI(self, xml_data = xmlui)
|
||||
|
||||
def _dynamicMenuEb(self, failure):
|
||||
dlg = wx.MessageDialog(self, _(u"Error while calling menu"),
|
||||
_('Error'),
|
||||
wx.OK | wx.ICON_ERROR
|
||||
)
|
||||
dlg.ShowModal()
|
||||
dlg.Destroy()
|
||||
|
||||
def createMenus(self):
|
||||
info(_("Creating menus"))
|
||||
connectMenu = wx.Menu()
|
||||
|
|
@ -142,8 +153,8 @@ class MainWindow(wx.Frame, QuickApp):
|
|||
#FIXME: do this in a more generic way (in quickapp)
|
||||
add_menus = self.bridge.getMenus()
|
||||
for menu in add_menus:
|
||||
category,item,type = menu
|
||||
assert(type=="NORMAL") #TODO: manage other types
|
||||
type_,category,name = menu
|
||||
assert(type_=="NORMAL") #TODO: manage other types
|
||||
menu_idx = self.menuBar.FindMenu(category)
|
||||
current_menu = None
|
||||
if menu_idx == wx.NOT_FOUND:
|
||||
|
|
@ -154,12 +165,11 @@ class MainWindow(wx.Frame, QuickApp):
|
|||
current_menu = self.menuBar.GetMenu(menu_idx)
|
||||
assert(current_menu != None)
|
||||
item_id = wx.NewId()
|
||||
help_string = self.bridge.getMenuHelp(category, item, type)
|
||||
current_menu.Append(item_id, item, help = help_string)
|
||||
help_string = self.bridge.getMenuHelp(category, name, type_)
|
||||
current_menu.Append(item_id, name, help = help_string)
|
||||
#now we register the event
|
||||
def event_answer(e):
|
||||
id = self.bridge.callMenu(category, item, type, self.profile)
|
||||
self.current_action_ids.add(id)
|
||||
self.bridge.asyncCallMenu(category, name, Const.MENU_NORMAL, self.profile, callback=self._dynamicMenuCb, errback=self._dynamicMenuEb)
|
||||
wx.EVT_MENU(self, item_id, event_answer)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue