changeset 78:56c02f4731f9

added selectValues for lists widgets that support multi-selection
author souliane <souliane@mailoo.org>
date Tue, 01 Apr 2014 20:58:12 +0200
parents e1655ba45fae
children 33677d99ebdf
files urwid_satext/sat_widgets.py
diffstat 1 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/urwid_satext/sat_widgets.py	Fri Mar 21 15:35:10 2014 +0100
+++ b/urwid_satext/sat_widgets.py	Tue Apr 01 20:58:12 2014 +0200
@@ -508,6 +508,21 @@
                 return
             idx+=1
 
+    def selectValues(self, values):
+        """Select all the given values"""
+        if self.single:
+            if values:
+                self.selectValue(values[-1])
+            return
+        self.unselectAll()
+        for value in values:
+            idx = 0
+            for widget in self.content:
+                if widget.getValue() == value:
+                    widget.setState(True)
+                    self.list_box.focus_position = idx
+                idx += 1
+
 
 class List(urwid.Widget):
     """FlowWidget list, same arguments as GenericList, with an additional one 'max_height'"""
@@ -555,6 +570,9 @@
     def selectValue(self, value):
         return self.genericList.selectValue(value)
 
+    def selectValues(self, values):
+        return self.genericList.selectValues(values)
+
     def render(self, size, focus=False):
         return self.displayWidget(size, focus).render(size, focus)