comparison src/tools/xml_tools.py @ 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 941fdf81958c
children 0046283a285d
comparison
equal deleted inserted replaced
2445:0199c0bd4c60 2446:bfd1e9d737c4
894 value_elt = self.xmlui.doc.createElement('value') 894 value_elt = self.xmlui.doc.createElement('value')
895 text = self.xmlui.doc.createTextNode(value) 895 text = self.xmlui.doc.createTextNode(value)
896 value_elt.appendChild(text) 896 value_elt.appendChild(text)
897 self.elem.appendChild(value_elt) 897 self.elem.appendChild(value_elt)
898 898
899 @property
900 def value(self):
901 return self.elem.firstChild.firstChild.wholeText
902
899 903
900 class PasswordWidget(StringWidget): 904 class PasswordWidget(StringWidget):
901 type = 'password' 905 type = 'password'
902 906
903 907
1018 # TODO: check flags incompatibily (noselect and multi) like in __init__ 1022 # TODO: check flags incompatibily (noselect and multi) like in __init__
1019 1023
1020 def setStyle(self, style): 1024 def setStyle(self, style):
1021 self.setStyles([style]) 1025 self.setStyles([style])
1022 1026
1027 @property
1028 def value(self):
1029 """Return the value of first selected option"""
1030 for child in self.elem.childNodes:
1031 if child.tagName == u'option' and child.getAttribute(u'selected') == u'true':
1032 return child.getAttribute(u'value')
1033 return u''
1023 1034
1024 class JidsListWidget(InputWidget): 1035 class JidsListWidget(InputWidget):
1025 """A list of text or jids where elements can be added/removed or modified""" 1036 """A list of text or jids where elements can be added/removed or modified"""
1026 type = 'jids_list' 1037 type = 'jids_list'
1027 1038