Mercurial > libervia-backend
comparison src/tools/xml_tools.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 | f021bf27a557 |
children | 73a0077f80cc |
comparison
equal
deleted
inserted
replaced
758:86224a13cc1d | 759:93bd868b8fb6 |
---|---|
217 | 217 |
218 | 218 |
219 class XMLUI(object): | 219 class XMLUI(object): |
220 """This class is used to create a user interface (form/window/parameters/etc) using SàT XML""" | 220 """This class is used to create a user interface (form/window/parameters/etc) using SàT XML""" |
221 | 221 |
222 def __init__(self, panel_type, layout="vertical", title=None): | 222 def __init__(self, panel_type, layout="vertical", title=None, submit_id=None): |
223 """Init SàT XML Panel | 223 """Init SàT XML Panel |
224 @param panel_type: one of | 224 @param panel_type: one of |
225 - window (new window) | 225 - window (new window) |
226 - form (formulaire, depend of the frontend, usually a panel with cancel/submit buttons) | 226 - form (formulaire, depend of the frontend, usually a panel with cancel/submit buttons) |
227 - param (parameters, presentatio depend of the frontend) | 227 - param (parameters, presentatio depend of the frontend) |
230 - horizontal: elements are disposed left to right | 230 - horizontal: elements are disposed left to right |
231 - pairs: elements come on two aligned columns | 231 - pairs: elements come on two aligned columns |
232 (usually one for a label, the next for the element) | 232 (usually one for a label, the next for the element) |
233 - tabs: elemens are in categories with tabs (notebook) | 233 - tabs: elemens are in categories with tabs (notebook) |
234 @param title: title or default if None | 234 @param title: title or default if None |
235 @param submit_id: callback id to call for panel_type we can submit (form, param) | |
235 """ | 236 """ |
236 if not panel_type in ['window', 'form', 'param']: | 237 if not panel_type in ['window', 'form', 'param']: |
237 error(_("Unknown panel type [%s]") % panel_type) | 238 error(_("Unknown panel type [%s]") % panel_type) |
238 assert(False) | 239 assert(False) |
239 self.type_ = panel_type | 240 self.type_ = panel_type |
242 self.doc = impl.createDocument(None, "sat_xmlui", None) | 243 self.doc = impl.createDocument(None, "sat_xmlui", None) |
243 top_element = self.doc.documentElement | 244 top_element = self.doc.documentElement |
244 top_element.setAttribute("type", panel_type) | 245 top_element.setAttribute("type", panel_type) |
245 if title: | 246 if title: |
246 top_element.setAttribute("title", title) | 247 top_element.setAttribute("title", title) |
248 if submit_id: | |
249 top_element.setAttribute("submit", submit_id) | |
247 self.parentTabsLayout = None # used only we have 'tabs' layout | 250 self.parentTabsLayout = None # used only we have 'tabs' layout |
248 self.currentCategory = None # used only we have 'tabs' layout | 251 self.currentCategory = None # used only we have 'tabs' layout |
249 self.currentLayout = None | 252 self.currentLayout = None |
250 self.changeLayout(layout) | 253 self.changeLayout(layout) |
251 | 254 |
367 @param name: name | 370 @param name: name |
368 @param value: label of the button | 371 @param value: label of the button |
369 @fields_back: list of names of field to give back when pushing the button | 372 @fields_back: list of names of field to give back when pushing the button |
370 """ | 373 """ |
371 elem = self._createElem('button', name, self.currentLayout) | 374 elem = self._createElem('button', name, self.currentLayout) |
372 elem.setAttribute('callback_id', callback_id) | 375 elem.setAttribute('callback', callback_id) |
373 elem.setAttribute('value', value) | 376 elem.setAttribute('value', value) |
374 for field in fields_back: | 377 for field in fields_back: |
375 fback_el = self.doc.createElement('field_back') | 378 fback_el = self.doc.createElement('field_back') |
376 fback_el.setAttribute('name', field) | 379 fback_el.setAttribute('name', field) |
377 elem.appendChild(fback_el) | 380 elem.appendChild(fback_el) |