1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-13 07:47:14 +03:00

theme.py: Some more tk.BitmapImage guarding, but using isinstance()

`type(...)` is probably incorrect, and `isinstance(...)` gets mypy to take
account of subclasses properly.
This commit is contained in:
Athanasius 2022-12-05 12:20:39 +00:00
parent 09d632bb34
commit 45043d9359
No known key found for this signature in database
GPG Key ID: 772697E181BB2767

View File

@ -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]