changeset 2446:bfd1e9d737c4

core (XMLUI): added value property for StringWidget and ListWidget
author Goffi <goffi@goffi.org>
date Thu, 30 Nov 2017 20:29:25 +0100
parents 0199c0bd4c60
children 9e692f09f367
files src/tools/xml_tools.py
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/tools/xml_tools.py	Thu Nov 30 20:27:22 2017 +0100
+++ b/src/tools/xml_tools.py	Thu Nov 30 20:29:25 2017 +0100
@@ -896,6 +896,10 @@
             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 @@
     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"""