Mercurial > libervia-backend
diff src/tools/common/template_xmlui.py @ 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 | 9878635586f3 |
children | 7fff98d64ab5 |
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"