template (xmlui): new properties + inheritance fix:
- "values" property in OptionsWidget return selected values. - "labels" property in OptionsWidget return list of labels - "for_name" property in LabelWidget return name of associated widget if set, else None - fixed inheritance for StringWidget and TextBoxWidget
This commit is contained in:
parent
f97b08382f
commit
59c6ab9973
1 changed files with 21 additions and 2 deletions
|
|
@ -69,6 +69,18 @@ class OptionsWidget(Widget):
|
|||
self.selected = selected
|
||||
self.style = style
|
||||
|
||||
@property
|
||||
def values(self):
|
||||
return self.selected
|
||||
|
||||
@property
|
||||
def labels(self):
|
||||
ret = []
|
||||
for value,label in self.options:
|
||||
if value in self.selected:
|
||||
ret.append(label)
|
||||
return ret
|
||||
|
||||
|
||||
class EmptyWidget(xmlui.EmptyWidget, Widget):
|
||||
|
||||
|
|
@ -83,12 +95,19 @@ class TextWidget(xmlui.TextWidget, ValueWidget):
|
|||
class LabelWidget(xmlui.LabelWidget, ValueWidget):
|
||||
type = u"label"
|
||||
|
||||
@property
|
||||
def for_name(self):
|
||||
try:
|
||||
return self._xmlui_for_name
|
||||
except AttributeError:
|
||||
return None
|
||||
|
||||
class StringWidget(xmlui.LabelWidget, InputWidget):
|
||||
|
||||
class StringWidget(xmlui.StringWidget, InputWidget):
|
||||
type = u"string"
|
||||
|
||||
|
||||
class TextBoxWidget(xmlui.LabelWidget, InputWidget):
|
||||
class TextBoxWidget(xmlui.TextWidget, InputWidget):
|
||||
type = u"textbox"
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue