Mercurial > libervia-desktop-kivy
changeset 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 |
files | cagou/core/cagou_main.py |
diffstat | 1 files changed, 12 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/cagou/core/cagou_main.py Fri Jan 17 18:44:35 2020 +0100 +++ b/cagou/core/cagou_main.py Fri Jan 17 18:44:35 2020 +0100 @@ -769,15 +769,24 @@ for internal use only! """ assert isinstance(widget, CagouWidget) - self._visible_widgets.setdefault(widget.__class__, []).append(widget) + log.debug(f"Visible widget: {widget}") + self._visible_widgets.setdefault(widget.__class__, set()).add(widget) + log.debug(f"visible widgets list: {self.getVisibleList(None)}") widget.onVisible() - def _removeVisibleWidget(self, widget): + def _removeVisibleWidget(self, widget, ignore_missing=False): """declare a widget not visible anymore for internal use only! """ - self._visible_widgets[widget.__class__].remove(widget) + log.debug(f"Widget not visible anymore: {widget}") + try: + self._visible_widgets[widget.__class__].remove(widget) + except KeyError as e: + if not ignore_missing: + log.error(f"trying to remove a not visible widget ({widget}): {e}") + return + log.debug(f"visible widgets list: {self.getVisibleList(None)}") if isinstance(widget, CagouWidget): widget.onNotVisible() if isinstance(widget, quick_widgets.QuickWidget):