frontends (XMLUI): implementation of read_only attributes for widgets String, TextBox, Password and Bool
This commit is contained in:
parent
2cc6d6549f
commit
e002d55880
1 changed files with 60 additions and 16 deletions
|
|
@ -191,6 +191,16 @@ class XMLUI(object):
|
|||
raise ValueError(_("XMLUI can have only one main container"))
|
||||
self._main_cont = value
|
||||
|
||||
def _isAttrSet(self, name, node):
|
||||
"""Returnw widget boolean attribute status
|
||||
|
||||
@param name: name of the attribute (e.g. "read_only")
|
||||
@param node: Node instance
|
||||
@return (bool): True if widget's attribute is set ("true")
|
||||
"""
|
||||
read_only = node.getAttribute(name) or "false"
|
||||
return read_only.lower().strip() == "true"
|
||||
|
||||
def _parseChilds(self, parent, current_node, wanted = ('container',), data = None):
|
||||
""" Recursively parse childNodes of an elemen
|
||||
@param parent: widget container with '_xmluiAppend' method
|
||||
|
|
@ -289,16 +299,16 @@ class XMLUI(object):
|
|||
style = node.getAttribute("style") or 'line'
|
||||
ctrl = self.widget_factory.createDividerWidget(parent, style)
|
||||
elif type_=="string":
|
||||
ctrl = self.widget_factory.createStringWidget(parent, value)
|
||||
ctrl = self.widget_factory.createStringWidget(parent, value, self._isAttrSet("read_only", node))
|
||||
self.ctrl_list[name] = ({'type':type_, 'control':ctrl})
|
||||
elif type_=="password":
|
||||
ctrl = self.widget_factory.createPasswordWidget(parent, value)
|
||||
ctrl = self.widget_factory.createPasswordWidget(parent, value, self._isAttrSet("read_only", node))
|
||||
self.ctrl_list[name] = ({'type':type_, 'control':ctrl})
|
||||
elif type_=="textbox":
|
||||
ctrl = self.widget_factory.createTextBoxWidget(parent, value)
|
||||
ctrl = self.widget_factory.createTextBoxWidget(parent, value, self._isAttrSet("read_only", node))
|
||||
self.ctrl_list[name] = ({'type':type_, 'control':ctrl})
|
||||
elif type_=="bool":
|
||||
ctrl = self.widget_factory.createBoolWidget(parent, value=='true')
|
||||
ctrl = self.widget_factory.createBoolWidget(parent, value=='true', self._isAttrSet("read_only", node))
|
||||
self.ctrl_list[name] = ({'type':type_, 'control':ctrl})
|
||||
elif type_ == "list":
|
||||
style = [] if node.getAttribute("multi") == 'yes' else ['single']
|
||||
|
|
|
|||
Loading…
Reference in a new issue