From 45043d9359abae25d8d17ef1d7765c6d3837e644 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Mon, 5 Dec 2022 12:20:39 +0000 Subject: [PATCH] theme.py: Some more tk.BitmapImage guarding, but using isinstance() `type(...)` is probably incorrect, and `isinstance(...)` gets mypy to take account of subclasses properly. --- theme.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/theme.py b/theme.py index e06ce27b..e9ace26f 100644 --- a/theme.py +++ b/theme.py @@ -312,7 +312,7 @@ class _Theme(object): # Apply current theme to a single widget def _update_widget(self, widget: tk.Widget | tk.BitmapImage) -> None: # noqa: CCR001, C901 if widget not in self.widgets: - if type(widget) == tk.Widget: + if isinstance(widget, tk.Widget): w_class = widget.winfo_class() w_keys: List[str] = widget.keys() @@ -403,7 +403,9 @@ class _Theme(object): # Switch menus for pair, gridopts in self.widgets_pair: for widget in pair: - widget.grid_remove() + if isinstance(widget, tk.Widget): + widget.grid_remove() + if isinstance(pair[0], tk.Menu): if theme == self.THEME_DEFAULT: root['menu'] = pair[0]