core/frontends (XMLUI): value can now be inserted as a <value/> element, if not present value attribute is tested, else empty string is used.
This commit is contained in:
parent
e002d55880
commit
8ca72f8a9f
1 changed files with 26 additions and 9 deletions
|
|
@ -201,8 +201,21 @@ class XMLUI(object):
|
|||
read_only = node.getAttribute(name) or "false"
|
||||
return read_only.lower().strip() == "true"
|
||||
|
||||
def _getChildNode(self, node, name):
|
||||
"""Return the first child node with the given name
|
||||
|
||||
@param node: Node instance
|
||||
@param name: name of the wanted node
|
||||
|
||||
@return: The found element or None
|
||||
"""
|
||||
for child in node.childNodes:
|
||||
if child.nodeName == name:
|
||||
return child
|
||||
return None
|
||||
|
||||
def _parseChilds(self, parent, current_node, wanted = ('container',), data = None):
|
||||
""" Recursively parse childNodes of an elemen
|
||||
"""Recursively parse childNodes of an elemen
|
||||
@param parent: widget container with '_xmluiAppend' method
|
||||
@param current_node: element from which childs will be parsed
|
||||
@param wanted: list of tag names that can be present in the childs to be SàT XMLUI compliant
|
||||
|
|
@ -281,15 +294,14 @@ class XMLUI(object):
|
|||
id_ = node.getAttribute("id")
|
||||
name = node.getAttribute("name")
|
||||
type_ = node.getAttribute("type")
|
||||
value = node.getAttribute("value") if node.hasAttribute('value') else u''
|
||||
value_elt = self._getChildNode(node, "value")
|
||||
if value_elt is not None:
|
||||
value = getText(value_elt)
|
||||
else:
|
||||
value = node.getAttribute("value") if node.hasAttribute('value') else u''
|
||||
if type_=="empty":
|
||||
ctrl = self.widget_factory.createEmptyWidget(parent)
|
||||
elif type_=="text":
|
||||
try:
|
||||
value = node.childNodes[0].wholeText
|
||||
except IndexError:
|
||||
# warning (_("text node has no child !"))
|
||||
pass # FIXME proper warning (this one is not OK with Libervia)
|
||||
ctrl = self.widget_factory.createTextWidget(parent, value)
|
||||
elif type_=="label":
|
||||
ctrl = self.widget_factory.createLabelWidget(parent, value)
|
||||
|
|
|
|||
Loading…
Reference in a new issue