mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-05-31 23:59:38 +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:
parent
09d632bb34
commit
45043d9359
4
theme.py
4
theme.py
@ -312,7 +312,7 @@ class _Theme(object):
|
|||||||
# Apply current theme to a single widget
|
# Apply current theme to a single widget
|
||||||
def _update_widget(self, widget: tk.Widget | tk.BitmapImage) -> None: # noqa: CCR001, C901
|
def _update_widget(self, widget: tk.Widget | tk.BitmapImage) -> None: # noqa: CCR001, C901
|
||||||
if widget not in self.widgets:
|
if widget not in self.widgets:
|
||||||
if type(widget) == tk.Widget:
|
if isinstance(widget, tk.Widget):
|
||||||
w_class = widget.winfo_class()
|
w_class = widget.winfo_class()
|
||||||
w_keys: List[str] = widget.keys()
|
w_keys: List[str] = widget.keys()
|
||||||
|
|
||||||
@ -403,7 +403,9 @@ class _Theme(object):
|
|||||||
# Switch menus
|
# Switch menus
|
||||||
for pair, gridopts in self.widgets_pair:
|
for pair, gridopts in self.widgets_pair:
|
||||||
for widget in pair:
|
for widget in pair:
|
||||||
|
if isinstance(widget, tk.Widget):
|
||||||
widget.grid_remove()
|
widget.grid_remove()
|
||||||
|
|
||||||
if isinstance(pair[0], tk.Menu):
|
if isinstance(pair[0], tk.Menu):
|
||||||
if theme == self.THEME_DEFAULT:
|
if theme == self.THEME_DEFAULT:
|
||||||
root['menu'] = pair[0]
|
root['menu'] = pair[0]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user