# HG changeset patch # User Goffi # Date 1509885847 -3600 # Node ID 69f979adb1d75c8b77f2f61d1f78da4303b4c68c # Parent 192ae573901a5db2164578016cc3e6ad9a3bc318 frotends(xmlui): fixed _xmlui_for_name attribute for labels diff -r 192ae573901a -r 69f979adb1d7 frontends/src/tools/xmlui.py --- a/frontends/src/tools/xmlui.py Sat Nov 04 22:11:45 2017 +0100 +++ b/frontends/src/tools/xmlui.py Sun Nov 05 13:44:07 2017 +0100 @@ -27,6 +27,7 @@ class_map = {} CLASS_PANEL = 'panel' CLASS_DIALOG = 'dialog' +CURRENT_LABEL = 'current_label' class InvalidXMLUI(Exception): pass @@ -396,7 +397,7 @@ self._parseChilds(cont, node, ('widget', 'container')) elif type_ == "label": cont = self.widget_factory.createLabelContainer(_xmlui_parent) - self._parseChilds(cont, node, ('widget', 'container'), {'current_label': None}) + self._parseChilds(cont, node, ('widget', 'container'), {CURRENT_LABEL: None}) elif type_ == "advanced_list": try: columns = int(node.getAttribute('columns')) @@ -460,14 +461,13 @@ value = node.getAttribute("value") if node.hasAttribute('value') else u'' if type_=="empty": ctrl = self.widget_factory.createEmptyWidget(_xmlui_parent) - if 'current_label' in data: - data['current_label'] = None + if CURRENT_LABEL in data: + data[CURRENT_LABEL] = None elif type_=="text": ctrl = self.widget_factory.createTextWidget(_xmlui_parent, value) elif type_=="label": ctrl = self.widget_factory.createLabelWidget(_xmlui_parent, value) - if 'current_label' in data: - data['current_label'] = ctrl + data[CURRENT_LABEL] = ctrl elif type_=="jid": ctrl = self.widget_factory.createJidWidget(_xmlui_parent, value) elif type_=="divider": @@ -537,10 +537,10 @@ ctrl._xmlui_name = name _xmlui_parent._xmluiAppend(ctrl) - if 'current_label' in data and not isinstance(ctrl, LabelWidget): + if CURRENT_LABEL in data and not isinstance(ctrl, LabelWidget): # this key is set in LabelContainer, when present # we can associate the label with the widget it is labelling - data['current_label']._xmlui_for_name = name + data.pop(CURRENT_LABEL)._xmlui_for_name = name else: raise NotImplementedError(_('Unknown tag [%s]') % node.nodeName)