comparison urwid_satext/sat_widgets.py @ 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
comparison
equal deleted inserted replaced
77:e1655ba45fae 78:56c02f4731f9
506 widget.setState(True) 506 widget.setState(True)
507 self.list_box.focus_position = idx 507 self.list_box.focus_position = idx
508 return 508 return
509 idx+=1 509 idx+=1
510 510
511 def selectValues(self, values):
512 """Select all the given values"""
513 if self.single:
514 if values:
515 self.selectValue(values[-1])
516 return
517 self.unselectAll()
518 for value in values:
519 idx = 0
520 for widget in self.content:
521 if widget.getValue() == value:
522 widget.setState(True)
523 self.list_box.focus_position = idx
524 idx += 1
525
511 526
512 class List(urwid.Widget): 527 class List(urwid.Widget):
513 """FlowWidget list, same arguments as GenericList, with an additional one 'max_height'""" 528 """FlowWidget list, same arguments as GenericList, with an additional one 'max_height'"""
514 signals = ['click','change'] 529 signals = ['click','change']
515 _sizing = frozenset(['flow']) 530 _sizing = frozenset(['flow'])
552 def changeValues(self, new_values): 567 def changeValues(self, new_values):
553 return self.genericList.changeValues(new_values) 568 return self.genericList.changeValues(new_values)
554 569
555 def selectValue(self, value): 570 def selectValue(self, value):
556 return self.genericList.selectValue(value) 571 return self.genericList.selectValue(value)
572
573 def selectValues(self, values):
574 return self.genericList.selectValues(values)
557 575
558 def render(self, size, focus=False): 576 def render(self, size, focus=False):
559 return self.displayWidget(size, focus).render(size, focus) 577 return self.displayWidget(size, focus).render(size, focus)
560 578
561 def rows(self, size, focus=False): 579 def rows(self, size, focus=False):