core (XMLUI): added value property for StringWidget and ListWidget

This commit is contained in:
Goffi 2017-11-30 20:29:25 +01:00
commit b845f7d49e

View file

@ -896,6 +896,10 @@ class StringWidget(InputWidget):
value_elt.appendChild(text)
self.elem.appendChild(value_elt)
@property
def value(self):
return self.elem.firstChild.firstChild.wholeText
class PasswordWidget(StringWidget):
type = 'password'
@ -1020,6 +1024,13 @@ class ListWidget(InputWidget):
def setStyle(self, style):
self.setStyles([style])
@property
def value(self):
"""Return the value of first selected option"""
for child in self.elem.childNodes:
if child.tagName == u'option' and child.getAttribute(u'selected') == u'true':
return child.getAttribute(u'value')
return u''
class JidsListWidget(InputWidget):
"""A list of text or jids where elements can be added/removed or modified"""