Mercurial > libervia-backend
diff frontends/src/wix/xmlui.py @ 759:93bd868b8fb6
backend, frontends: callbacks refactoring:
- launchAction is now async, and return a dictionary for its result
- no more action_id, actionResult* are deprecated
- callback system is about to be unified
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 24 Dec 2013 15:19:08 +0100 |
parents | 84a6e83157c2 |
children | 73a0077f80cc |
line wrap: on
line diff
--- a/frontends/src/wix/xmlui.py Tue Dec 24 15:19:08 2013 +0100 +++ b/frontends/src/wix/xmlui.py Tue Dec 24 15:19:08 2013 +0100 @@ -30,11 +30,13 @@ """Create an user interface from a SàT xml""" def __init__(self, host, xml_data='', title="Form", options = None, misc = None): - style = wx.DEFAULT_FRAME_STYLE & ~wx.CLOSE_BOX if 'NO_CANCEL' in options else wx.DEFAULT_FRAME_STYLE #FIXME: gof: Q&D tmp hack + if options is None: + options = [] + style = wx.DEFAULT_FRAME_STYLE & ~wx.CLOSE_BOX if 'NO_CANCEL' in options else wx.DEFAULT_FRAME_STYLE #FIXME: Q&D tmp hack super(XMLUI, self).__init__(None, title=title, style=style) self.host = host - self.options = options or [] + self.options = options self.misc = misc or {} self.ctrl_list = {} # usefull to access ctrl @@ -165,6 +167,7 @@ top= cat_dom.documentElement self.type = top.getAttribute("type") self.title = top .getAttribute("title") + self.submit_id = top.getAttribute("submit") or None if self.title: self.SetTitle(self.title) if top.nodeName != "sat_xmlui" or not self.type in ['form', 'param', 'window']: @@ -195,7 +198,6 @@ def onButtonClicked(self, event): """Called when a button is pushed""" callback_id, fields = event.GetEventObject().param_id - data = {"callback_id":callback_id} for field in fields: ctrl = self.ctrl_list[field] if isinstance(ctrl['control'], wx.ListBox): @@ -203,8 +205,7 @@ else: data[field] = ctrl['control'].GetValue() - id = self.host.bridge.launchAction("button", data, profile_key = self.host.profile) - self.host.current_action_ids.add(id) + self.host.launchAction(callback_id, None, profile_key = self.host.profile) event.Skip() def onFormSubmitted(self, event): @@ -224,6 +225,10 @@ self.host.current_action_ids.add(id) elif self.misc.has_key('callback'): self.misc['callback'](data) + + elif self.submit_id is not None: + data = dict(selected_values) + self.host.launchAction(self.submit_id, data, profile_key=self.host.profile) else: warning (_("The form data is not sent back, the type is not managed properly")) self.MakeModal(False)