Mercurial > libervia-backend
changeset 2379:42a54cbc1872
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
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 16 Oct 2017 07:28:36 +0200 |
parents | 3704cb959ae8 |
children | 59636c4db2d0 |
files | src/tools/common/template_xmlui.py |
diffstat | 1 files changed, 21 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/tools/common/template_xmlui.py Mon Oct 16 07:23:09 2017 +0200 +++ b/src/tools/common/template_xmlui.py Mon Oct 16 07:28:36 2017 +0200 @@ -69,6 +69,18 @@ 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 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"