mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-12 23:37:14 +03:00
prefs.py & related files: Fix up mypy type checking
* Some trivial. * As myNotebook.py's class is based on `ttk.Notebook`, typing changed to that.
This commit is contained in:
parent
3b0c7370cc
commit
f4b150960c
@ -216,7 +216,7 @@ class Logger:
|
||||
"""
|
||||
return self.logger_channel
|
||||
|
||||
def set_channels_loglevel(self, level: int) -> None:
|
||||
def set_channels_loglevel(self, level: int | str) -> None:
|
||||
"""
|
||||
Set the specified log level on the channels.
|
||||
|
||||
@ -226,7 +226,7 @@ class Logger:
|
||||
self.logger_channel.setLevel(level)
|
||||
self.logger_channel_rotating.setLevel(level)
|
||||
|
||||
def set_console_loglevel(self, level: int) -> None:
|
||||
def set_console_loglevel(self, level: int | str) -> None:
|
||||
"""
|
||||
Set the specified log level on the console channel.
|
||||
|
||||
|
@ -58,7 +58,7 @@ class Notebook(ttk.Notebook):
|
||||
class Frame(sys.platform == 'darwin' and tk.Frame or ttk.Frame): # type: ignore
|
||||
"""Custom t(t)k.Frame class to fix some display issues."""
|
||||
|
||||
def __init__(self, master: Optional[ttk.Frame] = None, **kw):
|
||||
def __init__(self, master: ttk.Notebook | None = None, **kw):
|
||||
if sys.platform == 'darwin':
|
||||
kw['background'] = kw.pop('background', PAGEBG)
|
||||
tk.Frame.__init__(self, master, **kw)
|
||||
|
8
plug.py
8
plug.py
@ -9,6 +9,8 @@ import tkinter as tk
|
||||
from builtins import object, str
|
||||
from typing import Any, Callable, List, Mapping, MutableMapping, Optional, Tuple
|
||||
|
||||
import ttk
|
||||
|
||||
import companion
|
||||
import myNotebook as nb # noqa: N813
|
||||
from config import config
|
||||
@ -118,7 +120,7 @@ class Plugin(object):
|
||||
|
||||
return None
|
||||
|
||||
def get_prefs(self, parent: tk.Frame, cmdr: str, is_beta: bool) -> Optional[tk.Frame]:
|
||||
def get_prefs(self, parent: ttk.Notebook, cmdr: str | None, is_beta: bool) -> Optional[tk.Frame]:
|
||||
"""
|
||||
If the plugin provides a prefs frame, create and return it.
|
||||
|
||||
@ -248,7 +250,7 @@ def notify_stop() -> Optional[str]:
|
||||
return error
|
||||
|
||||
|
||||
def notify_prefs_cmdr_changed(cmdr: str, is_beta: bool) -> None:
|
||||
def notify_prefs_cmdr_changed(cmdr: str | None, is_beta: bool) -> None:
|
||||
"""
|
||||
Notify plugins that the Cmdr was changed while the settings dialog is open.
|
||||
|
||||
@ -265,7 +267,7 @@ def notify_prefs_cmdr_changed(cmdr: str, is_beta: bool) -> None:
|
||||
logger.exception(f'Plugin "{plugin.name}" failed')
|
||||
|
||||
|
||||
def notify_prefs_changed(cmdr: str, is_beta: bool) -> None:
|
||||
def notify_prefs_changed(cmdr: str | None, is_beta: bool) -> None:
|
||||
"""
|
||||
Notify plugins that the settings dialog has been closed.
|
||||
|
||||
|
19
prefs.py
19
prefs.py
@ -19,7 +19,6 @@ from EDMCLogging import edmclogger, get_main_logger
|
||||
from hotkey import hotkeymgr
|
||||
from l10n import Translations
|
||||
from monitor import monitor
|
||||
from myNotebook import Notebook
|
||||
from theme import theme
|
||||
from ttkHyperlinkLabel import HyperlinkLabel
|
||||
|
||||
@ -279,7 +278,7 @@ class PreferencesDialog(tk.Toplevel):
|
||||
frame = ttk.Frame(self)
|
||||
frame.grid(sticky=tk.NSEW)
|
||||
|
||||
notebook = nb.Notebook(frame)
|
||||
notebook: ttk.Notebook = nb.Notebook(frame)
|
||||
notebook.bind('<<NotebookTabChanged>>', self.tabchanged) # Recompute on tab change
|
||||
|
||||
self.PADX = 10
|
||||
@ -333,7 +332,7 @@ class PreferencesDialog(tk.Toplevel):
|
||||
):
|
||||
self.geometry(f"+{position.left}+{position.top}")
|
||||
|
||||
def __setup_output_tab(self, root_notebook: nb.Notebook) -> None:
|
||||
def __setup_output_tab(self, root_notebook: ttk.Notebook) -> None:
|
||||
output_frame = nb.Frame(root_notebook)
|
||||
output_frame.columnconfigure(0, weight=1)
|
||||
|
||||
@ -418,13 +417,13 @@ class PreferencesDialog(tk.Toplevel):
|
||||
# LANG: Label for 'Output' Settings/Preferences tab
|
||||
root_notebook.add(output_frame, text=_('Output')) # Tab heading in settings
|
||||
|
||||
def __setup_plugin_tabs(self, notebook: Notebook) -> None:
|
||||
def __setup_plugin_tabs(self, notebook: ttk.Notebook) -> None:
|
||||
for plugin in plug.PLUGINS:
|
||||
plugin_frame = plugin.get_prefs(notebook, monitor.cmdr, monitor.is_beta)
|
||||
if plugin_frame:
|
||||
notebook.add(plugin_frame, text=plugin.name)
|
||||
|
||||
def __setup_config_tab(self, notebook: Notebook) -> None: # noqa: CCR001
|
||||
def __setup_config_tab(self, notebook: ttk.Notebook) -> None: # noqa: CCR001
|
||||
config_frame = nb.Frame(notebook)
|
||||
config_frame.columnconfigure(1, weight=1)
|
||||
row = AutoInc(start=1)
|
||||
@ -675,7 +674,7 @@ class PreferencesDialog(tk.Toplevel):
|
||||
# LANG: Label for 'Configuration' tab in Settings
|
||||
notebook.add(config_frame, text=_('Configuration'))
|
||||
|
||||
def __setup_privacy_tab(self, notebook: Notebook) -> None:
|
||||
def __setup_privacy_tab(self, notebook: ttk.Notebook) -> None:
|
||||
frame = nb.Frame(notebook)
|
||||
self.hide_multicrew_captain = tk.BooleanVar(value=config.get_bool('hide_multicrew_captain', default=False))
|
||||
self.hide_private_group = tk.BooleanVar(value=config.get_bool('hide_private_group', default=False))
|
||||
@ -697,7 +696,7 @@ class PreferencesDialog(tk.Toplevel):
|
||||
|
||||
notebook.add(frame, text=_('Privacy')) # LANG: Preferences privacy tab title
|
||||
|
||||
def __setup_appearance_tab(self, notebook: Notebook) -> None:
|
||||
def __setup_appearance_tab(self, notebook: ttk.Notebook) -> None:
|
||||
self.languages = Translations.available_names()
|
||||
# Appearance theme and language setting
|
||||
# LANG: The system default language choice in Settings > Appearance
|
||||
@ -887,7 +886,7 @@ class PreferencesDialog(tk.Toplevel):
|
||||
# LANG: Label for Settings > Appearance tab
|
||||
notebook.add(appearance_frame, text=_('Appearance')) # Tab heading in settings
|
||||
|
||||
def __setup_plugin_tab(self, notebook: Notebook) -> None: # noqa: CCR001
|
||||
def __setup_plugin_tab(self, notebook: ttk.Notebook) -> None: # noqa: CCR001
|
||||
# Plugin settings and info
|
||||
plugins_frame = nb.Frame(notebook)
|
||||
plugins_frame.columnconfigure(0, weight=1)
|
||||
@ -1188,8 +1187,8 @@ class PreferencesDialog(tk.Toplevel):
|
||||
:return: "break" as a literal, to halt processing
|
||||
"""
|
||||
good = hotkeymgr.fromevent(event)
|
||||
if good:
|
||||
(hotkey_code, hotkey_mods) = good
|
||||
if good and isinstance(good, tuple):
|
||||
hotkey_code, hotkey_mods = good
|
||||
event.widget.delete(0, tk.END)
|
||||
event.widget.insert(0, hotkeymgr.display(hotkey_code, hotkey_mods))
|
||||
if hotkey_code:
|
||||
|
Loading…
x
Reference in New Issue
Block a user