From eaaa6fead08d95b6b58a5c24ca2c7e12cebf5ddd Mon Sep 17 00:00:00 2001 From: Athanasius Date: Thu, 22 Dec 2022 17:25:13 +0000 Subject: [PATCH] Correctly type `theme` ui_scale variables Technically `theme.startup_ui_scale` should be `float` to match with `default_ui_scale` from tkinter, but we store it in the config as `int`, so go with that. --- EDMarketConnector.py | 5 ++++- theme.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/EDMarketConnector.py b/EDMarketConnector.py index 388659ee..c5831e74 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -2089,10 +2089,13 @@ sys.path: {sys.path}''' if not ui_scale: ui_scale = 100 config.set('ui_scale', ui_scale) + theme.default_ui_scale = root.tk.call('tk', 'scaling') logger.trace_if('tk', f'Default tk scaling = {theme.default_ui_scale}') theme.startup_ui_scale = ui_scale - root.tk.call('tk', 'scaling', theme.default_ui_scale * float(ui_scale) / 100.0) + if theme.default_ui_scale is not None: + root.tk.call('tk', 'scaling', theme.default_ui_scale * float(ui_scale) / 100.0) + app = AppWindow(root) def messagebox_not_py3(): diff --git a/theme.py b/theme.py index 45886f16..b5d51484 100644 --- a/theme.py +++ b/theme.py @@ -137,8 +137,8 @@ class _Theme(object): self.widgets_pair: List = [] self.defaults: Dict = {} self.current: Dict = {} - self.default_ui_scale = None # None == not yet known - self.startup_ui_scale = None + self.default_ui_scale: float | None = None # None == not yet known + self.startup_ui_scale: int | None = None def register(self, widget: tk.Widget | tk.BitmapImage) -> None: # noqa: CCR001, C901 # Note widget and children for later application of a theme. Note if