Mercurial > libervia-backend
comparison sat_frontends/tools/xmlui.py @ 2995:5ecce65631a2
frontends (xmlui): fixed crash when CURRENT_LABEL is None:
fix 323
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 11 Jul 2019 09:21:10 +0200 |
parents | 5ba98fd6c9a4 |
children | ab2696e34d29 |
comparison
equal
deleted
inserted
replaced
2994:94708a7d3ecf | 2995:5ecce65631a2 |
---|---|
464 cont = self.widget_factory.createPairsContainer(_xmlui_parent) | 464 cont = self.widget_factory.createPairsContainer(_xmlui_parent) |
465 self._parseChilds(cont, node, ("widget", "container")) | 465 self._parseChilds(cont, node, ("widget", "container")) |
466 elif type_ == "label": | 466 elif type_ == "label": |
467 cont = self.widget_factory.createLabelContainer(_xmlui_parent) | 467 cont = self.widget_factory.createLabelContainer(_xmlui_parent) |
468 self._parseChilds( | 468 self._parseChilds( |
469 # FIXME: the "None" value for CURRENT_LABEL doesn't seem | |
470 # used or even useful, it should probably be removed | |
471 # and all "is not None" tests for it should be removed too | |
472 # to be checked for 0.8 | |
469 cont, node, ("widget", "container"), {CURRENT_LABEL: None} | 473 cont, node, ("widget", "container"), {CURRENT_LABEL: None} |
470 ) | 474 ) |
471 elif type_ == "advanced_list": | 475 elif type_ == "advanced_list": |
472 try: | 476 try: |
473 columns = int(node.getAttribute("columns")) | 477 columns = int(node.getAttribute("columns")) |
539 or self._whitelist is not None | 543 or self._whitelist is not None |
540 and name not in self._whitelist | 544 and name not in self._whitelist |
541 ): | 545 ): |
542 # current widget is ignored, but there may be already a label | 546 # current widget is ignored, but there may be already a label |
543 if CURRENT_LABEL in data: | 547 if CURRENT_LABEL in data: |
544 # if so, we remove it from parent | 548 curr_label = data.pop(CURRENT_LABEL) |
545 _xmlui_parent._xmluiRemove(data.pop(CURRENT_LABEL)) | 549 if curr_label is not None: |
550 # if so, we remove it from parent | |
551 _xmlui_parent._xmluiRemove(curr_label) | |
546 continue | 552 continue |
547 type_ = node.getAttribute("type") | 553 type_ = node.getAttribute("type") |
548 value_elt = self._getChildNode(node, "value") | 554 value_elt = self._getChildNode(node, "value") |
549 if value_elt is not None: | 555 if value_elt is not None: |
550 value = getText(value_elt) | 556 value = getText(value_elt) |
687 ctrl._xmluiOnChange(self.onChangeInternal) | 693 ctrl._xmluiOnChange(self.onChangeInternal) |
688 | 694 |
689 ctrl._xmlui_name = name | 695 ctrl._xmlui_name = name |
690 _xmlui_parent._xmluiAppend(ctrl) | 696 _xmlui_parent._xmluiAppend(ctrl) |
691 if CURRENT_LABEL in data and not isinstance(ctrl, LabelWidget): | 697 if CURRENT_LABEL in data and not isinstance(ctrl, LabelWidget): |
692 # this key is set in LabelContainer, when present | 698 curr_label = data.pop(CURRENT_LABEL) |
693 # we can associate the label with the widget it is labelling | 699 if curr_label is not None: |
694 data.pop(CURRENT_LABEL)._xmlui_for_name = name | 700 # this key is set in LabelContainer, when present |
701 # we can associate the label with the widget it is labelling | |
702 curr_label._xmlui_for_name = name | |
695 | 703 |
696 else: | 704 else: |
697 raise NotImplementedError(_("Unknown tag [%s]") % node.nodeName) | 705 raise NotImplementedError(_("Unknown tag [%s]") % node.nodeName) |
698 | 706 |
699 def constructUI(self, parsed_dom, post_treat=None): | 707 def constructUI(self, parsed_dom, post_treat=None): |