comparison src/tools/common/template_xmlui.py @ 2455:7b02372f8734

template (xmlui): added labels property in ValueWidget (actually return values) and values property in OptionsWidget
author Goffi <goffi@goffi.org>
date Mon, 04 Dec 2017 00:45:07 +0100
parents 49884c579266
children 0046283a285d
comparison
equal deleted inserted replaced
2454:06ff33052354 2455:7b02372f8734
51 51
52 @property 52 @property
53 def values(self): 53 def values(self):
54 return [self.value] 54 return [self.value]
55 55
56 @property
57 def labels(self):
58 # helper property, there is not label for ValueWidget
59 # but using labels make rendering more easy (one single method to call)
60 # values are actually returned
61 return [self.value]
62
56 63
57 class InputWidget(ValueWidget): 64 class InputWidget(ValueWidget):
58 65
59 def __init__(self, xmlui_parent, value, read_only=False): 66 def __init__(self, xmlui_parent, value, read_only=False):
60 super(InputWidget, self).__init__(xmlui_parent, value) 67 super(InputWidget, self).__init__(xmlui_parent, value)
69 self.selected = selected 76 self.selected = selected
70 self.style = style 77 self.style = style
71 78
72 @property 79 @property
73 def values(self): 80 def values(self):
74 return self.selected 81 for value, label in self.items:
82 yield value
75 83
76 @property 84 @property
77 def labels(self): 85 def labels(self):
78 """return only labels from self.items""" 86 """return only labels from self.items"""
79 for value, label in self.items: 87 for value, label in self.items: