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!
This commit is contained in:
souliane 2014-04-01 21:21:13 +02:00
commit 608e2ba9fa

View file

@ -122,14 +122,16 @@ class ButtonWidget(EventWidget, WixWidget, xmlui.ButtonWidget, wx.Button):
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 @@ class ListWidget(EventWidget, WixWidget, xmlui.ListWidget, wx.ListBox):
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()]