Mercurial > libervia-backend
diff frontends/src/tools/xmlui.py @ 1085:7a39ae3950f7
frontends (XMLUI): implementation of read_only attributes for widgets String, TextBox, Password and Bool
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 25 Jun 2014 14:01:56 +0200 |
parents | d2e612a45e76 |
children | 2cb30f46e560 |
line wrap: on
line diff
--- a/frontends/src/tools/xmlui.py Wed Jun 25 14:01:55 2014 +0200 +++ b/frontends/src/tools/xmlui.py Wed Jun 25 14:01:56 2014 +0200 @@ -191,6 +191,16 @@ 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 @@ 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']