Mercurial > libervia-backend
comparison frontends/src/tools/xmlui.py @ 968:75f3b3b430ff
tools, frontends, memory: param definition and XMLUI handle multi-selection for list widgets:
- we need to update urwid_satext to revision 79
- no more "value" attribute value in the "list" element, use
HTML-style "select" attribute in the "option" elements instead
- /!\ param saving do not handle multiple values yet!
author | souliane <souliane@mailoo.org> |
---|---|
date | Tue, 01 Apr 2014 21:21:13 +0200 |
parents | 3ee2ec7ec010 |
children | 5c7707c958d8 |
comparison
equal
deleted
inserted
replaced
967:242bd4fc654c | 968:75f3b3b430ff |
---|---|
299 ctrl = self.widget_factory.createTextBoxWidget(parent, value) | 299 ctrl = self.widget_factory.createTextBoxWidget(parent, value) |
300 self.ctrl_list[name] = ({'type':type_, 'control':ctrl}) | 300 self.ctrl_list[name] = ({'type':type_, 'control':ctrl}) |
301 elif type_=="bool": | 301 elif type_=="bool": |
302 ctrl = self.widget_factory.createBoolWidget(parent, value=='true') | 302 ctrl = self.widget_factory.createBoolWidget(parent, value=='true') |
303 self.ctrl_list[name] = ({'type':type_, 'control':ctrl}) | 303 self.ctrl_list[name] = ({'type':type_, 'control':ctrl}) |
304 elif type_=="list": | 304 elif type_ == "list": |
305 style=[] if node.getAttribute("multi")=='yes' else ['single'] | 305 style = [] if node.getAttribute("multi") == 'yes' else ['single'] |
306 _options = [(option.getAttribute("value"), option.getAttribute("label")) for option in node.getElementsByTagName("option")] | 306 _options = [(option.getAttribute("value"), option.getAttribute("label")) for option in node.getElementsByTagName("option")] |
307 ctrl = self.widget_factory.createListWidget(parent, _options, style) | 307 _selected = [option.getAttribute("value") for option in node.getElementsByTagName("option") if option.getAttribute('selected') == 'true'] |
308 ctrl._xmluiSelectValue(node.getAttribute("value")) | 308 ctrl = self.widget_factory.createListWidget(parent, _options, _selected, style) |
309 self.ctrl_list[name] = ({'type':type_, 'control':ctrl}) | 309 self.ctrl_list[name] = ({'type': type_, 'control': ctrl}) |
310 elif type_=="button": | 310 elif type_=="button": |
311 callback_id = node.getAttribute("callback") | 311 callback_id = node.getAttribute("callback") |
312 ctrl = self.widget_factory.createButtonWidget(parent, value, self.onButtonPress) | 312 ctrl = self.widget_factory.createButtonWidget(parent, value, self.onButtonPress) |
313 ctrl._xmlui_param_id = (callback_id,[field.getAttribute('name') for field in node.getElementsByTagName("field_back")]) | 313 ctrl._xmlui_param_id = (callback_id, [field.getAttribute('name') for field in node.getElementsByTagName("field_back")]) |
314 else: | 314 else: |
315 print(_("FIXME FIXME FIXME: widget type [%s] is not implemented") % type_) | 315 print(_("FIXME FIXME FIXME: widget type [%s] is not implemented") % type_) |
316 raise NotImplementedError(_("FIXME FIXME FIXME: type [%s] is not implemented") % type_) | 316 raise NotImplementedError(_("FIXME FIXME FIXME: type [%s] is not implemented") % type_) |
317 | 317 |
318 if self.type == 'param' and type_ != 'text': | 318 if self.type == 'param' and type_ != 'text': |
406 data = {} | 406 data = {} |
407 for field in fields: | 407 for field in fields: |
408 escaped = self.escape(field) | 408 escaped = self.escape(field) |
409 ctrl = self.ctrl_list[field] | 409 ctrl = self.ctrl_list[field] |
410 if isinstance(ctrl['control'], ListWidget): | 410 if isinstance(ctrl['control'], ListWidget): |
411 data[escaped] = u'\t'.join(ctrl['control']._xmluiGetSelected()) | 411 data[escaped] = u'\t'.join(ctrl['control']._xmluiGetSelectedValues()) |
412 else: | 412 else: |
413 data[escaped] = ctrl['control']._xmluiGetValue() | 413 data[escaped] = ctrl['control']._xmluiGetValue() |
414 self._xmluiLaunchAction(callback_id, data) | 414 self._xmluiLaunchAction(callback_id, data) |
415 | 415 |
416 def onFormSubmitted(self, ignore=None): | 416 def onFormSubmitted(self, ignore=None): |