Mercurial > libervia-desktop-kivy
comparison cagou/core/cagou_main.py @ 352:434f770fe55b
core (Cagou): add debug log for widget visibility + ignore_missing:
- debug log are now use to show which widget are made (in)visible, and to show the list of
currently visible widgets
- "ignore_missing" can be used in _removeVisibleWidget when we can expect that a widget is
missing in visible widgets list.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 17 Jan 2020 18:44:35 +0100 |
parents | e9d3c3793f94 |
children | 19422bbd9c8e |
comparison
equal
deleted
inserted
replaced
351:e9d3c3793f94 | 352:434f770fe55b |
---|---|
767 """declare a widget visible | 767 """declare a widget visible |
768 | 768 |
769 for internal use only! | 769 for internal use only! |
770 """ | 770 """ |
771 assert isinstance(widget, CagouWidget) | 771 assert isinstance(widget, CagouWidget) |
772 self._visible_widgets.setdefault(widget.__class__, []).append(widget) | 772 log.debug(f"Visible widget: {widget}") |
773 self._visible_widgets.setdefault(widget.__class__, set()).add(widget) | |
774 log.debug(f"visible widgets list: {self.getVisibleList(None)}") | |
773 widget.onVisible() | 775 widget.onVisible() |
774 | 776 |
775 def _removeVisibleWidget(self, widget): | 777 def _removeVisibleWidget(self, widget, ignore_missing=False): |
776 """declare a widget not visible anymore | 778 """declare a widget not visible anymore |
777 | 779 |
778 for internal use only! | 780 for internal use only! |
779 """ | 781 """ |
780 self._visible_widgets[widget.__class__].remove(widget) | 782 log.debug(f"Widget not visible anymore: {widget}") |
783 try: | |
784 self._visible_widgets[widget.__class__].remove(widget) | |
785 except KeyError as e: | |
786 if not ignore_missing: | |
787 log.error(f"trying to remove a not visible widget ({widget}): {e}") | |
788 return | |
789 log.debug(f"visible widgets list: {self.getVisibleList(None)}") | |
781 if isinstance(widget, CagouWidget): | 790 if isinstance(widget, CagouWidget): |
782 widget.onNotVisible() | 791 widget.onNotVisible() |
783 if isinstance(widget, quick_widgets.QuickWidget): | 792 if isinstance(widget, quick_widgets.QuickWidget): |
784 self.widgets.deleteWidget(widget) | 793 self.widgets.deleteWidget(widget) |
785 | 794 |