mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2026-10-29 01:26:08 +03:00
Merge pull request #2538 from inutt/fix/--/linting
Fix mypy linting issues
This commit is contained in:
5 files changed
+33
-20
No files matched your search
+13
-14
@@ -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:
|
||||
|
||||
+1
-1
@@ -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:
|
||||
|
||||
+12
-4
@@ -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)
|
||||
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
+2
-1
@@ -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(
|
||||
|
||||
Reference in new issue
Block a user