diff --git a/common_utils.py b/common_utils.py index a6f78356..ce3c7986 100644 --- a/common_utils.py +++ b/common_utils.py @@ -29,23 +29,22 @@ def ensure_on_screen(self, parent: tk.Tk): :param self: The calling class instance of tk.TopLevel :param parent: The parent window """ - if sys.platform != 'win32': - return - try: - # Get monitor info for the monitor containing the parent window - monitor = win32api.MonitorFromWindow(parent.winfo_id(), win32con.MONITOR_DEFAULTTONEAREST) - monitor_info = win32api.GetMonitorInfo(monitor) - work_area = monitor_info['Work'] # Gets the working area (excludes taskbar) + if sys.platform == 'win32': + try: + # Get monitor info for the monitor containing the parent window + monitor = win32api.MonitorFromWindow(parent.winfo_id(), win32con.MONITOR_DEFAULTTONEAREST) + monitor_info = win32api.GetMonitorInfo(monitor) + work_area = monitor_info['Work'] # Gets the working area (excludes taskbar) - # Calculate optimal position - x = max(work_area[0], min(parent.winfo_rootx(), work_area[2] - self.winfo_width())) - y = max(work_area[1], min(parent.winfo_rooty(), work_area[3] - self.winfo_height())) + # Calculate optimal position + x = max(work_area[0], min(parent.winfo_rootx(), work_area[2] - self.winfo_width())) + y = max(work_area[1], min(parent.winfo_rooty(), work_area[3] - self.winfo_height())) - # Update window position - self.geometry(f"+{x}+{y}") + # Update window position + self.geometry(f"+{x}+{y}") - except Exception as e: - logger.debug(f"Failed to ensure window is on screen: {e}") + except Exception as e: + logger.debug(f"Failed to ensure window is on screen: {e}") def log_locale(prefix: str) -> None: diff --git a/config/linux.py b/config/linux.py index 27e4d6bf..1b5ac924 100644 --- a/config/linux.py +++ b/config/linux.py @@ -75,7 +75,7 @@ class LinuxConfigMinimal: def close(self) -> None: """Release resources (stub).""" - self.config = None + del self.config def linux_helper(config: Config) -> Config: diff --git a/myNotebook.py b/myNotebook.py index 7098fad3..119f33bb 100644 --- a/myNotebook.py +++ b/myNotebook.py @@ -51,10 +51,18 @@ class Label(ttk.Label): """Custom ttk.Label class to fix some display issues.""" def __init__(self, master: ttk.Frame | None = None, **kw): - kw['foreground'] = kw.pop('foreground', PAGEFG if sys.platform == 'win32' - else ttk.Style().lookup('TLabel', 'foreground')) - kw['background'] = kw.pop('background', PAGEBG if sys.platform == 'win32' - else ttk.Style().lookup('TLabel', 'background')) + if sys.platform == 'win32': + fg_color = PAGEFG + else: + fg_color = ttk.Style().lookup('TLabel', 'foreground') + + if sys.platform == 'win32': + bg_color = PAGEBG + else: + bg_color = ttk.Style().lookup('TLabel', 'background') + + kw['foreground'] = kw.pop('foreground', fg_color) + kw['background'] = kw.pop('background', bg_color) super().__init__(master, **kw) diff --git a/prefs.py b/prefs.py index f122b9e3..65feb24b 100644 --- a/prefs.py +++ b/prefs.py @@ -309,6 +309,11 @@ class PreferencesDialog(tk.Toplevel): self.cmdrchanged() self.themevarchanged() + # Init hotkey attributes to avoid linter errors + self.hotkey_text: ttk.Entry + self.hotkey_only_btn: nb.Checkbutton + self.hotkey_play_btn: nb.Checkbutton + # disable hotkey for the duration hotkeymgr.unregister() diff --git a/util_ships.py b/util_ships.py index 8abbe20f..4f99e731 100644 --- a/util_ships.py +++ b/util_ships.py @@ -6,6 +6,7 @@ Licensed under the GNU General Public License. See LICENSE file. """ import os +import sys from pathlib import Path from edmc_data import ship_name_map @@ -18,7 +19,7 @@ def ship_file_name(ship_name: str, ship_type: str) -> str: name = Path(name).with_suffix("").name # Check if the name is a reserved filename - if os.path.isreserved(name): + if sys.platform == 'win32' and os.path.isreserved(name): name += "_" return name.translate(