diff frontends/src/wix/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/wix/xmlui.py	Tue Apr 01 16:27:59 2014 +0200
+++ b/frontends/src/wix/xmlui.py	Tue Apr 01 21:21:13 2014 +0200
@@ -122,14 +122,16 @@
         self._xmlui_click_callback(event.GetEventObject())
         event.Skip()
 
+
 class ListWidget(EventWidget, WixWidget, xmlui.ListWidget, wx.ListBox):
     _xmlui_change_event = wx.EVT_LISTBOX
 
-    def __init__(self, parent, options, flags):
+    def __init__(self, parent, options, selected, flags):
         styles = wx.LB_MULTIPLE if not 'single' in flags else wx.LB_SINGLE
         wx.ListBox.__init__(self, parent, -1, choices=[option[1] for option in options], style=styles)
         self._xmlui_attr_map = {label: value for value, label in options}
         self._xmlui_proportion = 1
+        self._xmluiSelectValues(selected)
 
     def _xmluiSelectValue(self, value):
         try:
@@ -140,6 +142,10 @@
         for idx in xrange(self.GetCount()):
             self.SetSelection(idx, self.GetString(idx) == label)
 
+    def _xmluiSelectValues(self, values):
+        for value in values:
+            self._xmluiSelectValue(value)
+
     def _xmluiGetSelectedValues(self):
         ret = []
         labels = [self.GetString(idx) for idx in self.GetSelections()]