comparison sat/tools/common/template_xmlui.py @ 3573:813595f88612

merge changes from main branch
author Goffi <goffi@goffi.org>
date Thu, 17 Jun 2021 13:05:58 +0200
parents 185601bc0cd3
children 524856bd7b19
comparison
equal deleted inserted replaced
3541:888109774673 3573:813595f88612
88 def values(self): 88 def values(self):
89 for value, label in self.items: 89 for value, label in self.items:
90 yield value 90 yield value
91 91
92 @property 92 @property
93 def value(self):
94 if self.multi or self.no_select or len(self.selected) != 1:
95 raise ValueError(
96 "Can't get value for list with multiple selections or nothing selected"
97 )
98 return self.selected[0]
99
100 @property
93 def labels(self): 101 def labels(self):
94 """return only labels from self.items""" 102 """return only labels from self.items"""
95 for value, label in self.items: 103 for value, label in self.items:
96 yield label 104 yield label
97 105
109 117
110 @property 118 @property
111 def no_select(self): 119 def no_select(self):
112 return "noselect" in self.style 120 return "noselect" in self.style
113 121
122 @property
123 def multi(self):
124 return "multi" in self.style
125
114 126
115 class EmptyWidget(xmlui.EmptyWidget, Widget): 127 class EmptyWidget(xmlui.EmptyWidget, Widget):
116 def __init__(self, _xmlui_parent): 128 def __init__(self, _xmlui_parent):
117 Widget.__init__(self) 129 Widget.__init__(self)
118 130