Mercurial > libervia-backend
comparison 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 |
comparison
equal
deleted
inserted
replaced
2378:3704cb959ae8 | 2379:42a54cbc1872 |
---|---|
67 super(OptionsWidget, self).__init__(xmlui_parent) | 67 super(OptionsWidget, self).__init__(xmlui_parent) |
68 self.options = options | 68 self.options = options |
69 self.selected = selected | 69 self.selected = selected |
70 self.style = style | 70 self.style = style |
71 | 71 |
72 @property | |
73 def values(self): | |
74 return self.selected | |
75 | |
76 @property | |
77 def labels(self): | |
78 ret = [] | |
79 for value,label in self.options: | |
80 if value in self.selected: | |
81 ret.append(label) | |
82 return ret | |
83 | |
72 | 84 |
73 class EmptyWidget(xmlui.EmptyWidget, Widget): | 85 class EmptyWidget(xmlui.EmptyWidget, Widget): |
74 | 86 |
75 def __init__(self, _xmlui_parent): | 87 def __init__(self, _xmlui_parent): |
76 Widget.__init__(self) | 88 Widget.__init__(self) |
81 | 93 |
82 | 94 |
83 class LabelWidget(xmlui.LabelWidget, ValueWidget): | 95 class LabelWidget(xmlui.LabelWidget, ValueWidget): |
84 type = u"label" | 96 type = u"label" |
85 | 97 |
98 @property | |
99 def for_name(self): | |
100 try: | |
101 return self._xmlui_for_name | |
102 except AttributeError: | |
103 return None | |
86 | 104 |
87 class StringWidget(xmlui.LabelWidget, InputWidget): | 105 |
106 class StringWidget(xmlui.StringWidget, InputWidget): | |
88 type = u"string" | 107 type = u"string" |
89 | 108 |
90 | 109 |
91 class TextBoxWidget(xmlui.LabelWidget, InputWidget): | 110 class TextBoxWidget(xmlui.TextWidget, InputWidget): |
92 type = u"textbox" | 111 type = u"textbox" |
93 | 112 |
94 | 113 |
95 class ListWidget(xmlui.ListWidget, OptionsWidget): | 114 class ListWidget(xmlui.ListWidget, OptionsWidget): |
96 type = u"list" | 115 type = u"list" |