diff 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
line wrap: on
line diff
--- a/frontends/src/tools/xmlui.py	Tue Apr 01 16:27:59 2014 +0200
+++ b/frontends/src/tools/xmlui.py	Tue Apr 01 21:21:13 2014 +0200
@@ -301,16 +301,16 @@
                 elif type_=="bool":
                     ctrl = self.widget_factory.createBoolWidget(parent, value=='true')
                     self.ctrl_list[name] = ({'type':type_, 'control':ctrl})
-                elif type_=="list":
-                    style=[] if node.getAttribute("multi")=='yes' else ['single']
+                elif type_ == "list":
+                    style = [] if node.getAttribute("multi") == 'yes' else ['single']
                     _options = [(option.getAttribute("value"), option.getAttribute("label")) for option in node.getElementsByTagName("option")]
-                    ctrl = self.widget_factory.createListWidget(parent, _options, style)
-                    ctrl._xmluiSelectValue(node.getAttribute("value"))
-                    self.ctrl_list[name] = ({'type':type_, 'control':ctrl})
+                    _selected = [option.getAttribute("value") for option in node.getElementsByTagName("option") if option.getAttribute('selected') == 'true']
+                    ctrl = self.widget_factory.createListWidget(parent, _options, _selected, style)
+                    self.ctrl_list[name] = ({'type': type_, 'control': ctrl})
                 elif type_=="button":
                     callback_id = node.getAttribute("callback")
                     ctrl = self.widget_factory.createButtonWidget(parent, value, self.onButtonPress)
-                    ctrl._xmlui_param_id = (callback_id,[field.getAttribute('name') for field in node.getElementsByTagName("field_back")])
+                    ctrl._xmlui_param_id = (callback_id, [field.getAttribute('name') for field in node.getElementsByTagName("field_back")])
                 else:
                     print(_("FIXME FIXME FIXME: widget type [%s] is not implemented") % type_)
                     raise NotImplementedError(_("FIXME FIXME FIXME: type [%s] is not implemented") % type_)
@@ -408,7 +408,7 @@
             escaped = self.escape(field)
             ctrl = self.ctrl_list[field]
             if isinstance(ctrl['control'], ListWidget):
-                data[escaped] = u'\t'.join(ctrl['control']._xmluiGetSelected())
+                data[escaped] = u'\t'.join(ctrl['control']._xmluiGetSelectedValues())
             else:
                 data[escaped] = ctrl['control']._xmluiGetValue()
         self._xmluiLaunchAction(callback_id, data)