From ea451f7137822aa1c2c726f89c888e5b3affeaa1 Mon Sep 17 00:00:00 2001 From: Bruno Marques Date: Mon, 27 May 2024 22:03:34 +0100 Subject: [PATCH] On second thought, nah --- EDMarketConnector.py | 9 --------- config/__init__.py | 14 -------------- .../examples/ttk_catalog/load.py | 10 +++++++--- plug.py | 16 ++-------------- 4 files changed, 9 insertions(+), 40 deletions(-) rename plugins/_ttk_catalog.py => docs/examples/ttk_catalog/load.py (98%) diff --git a/EDMarketConnector.py b/EDMarketConnector.py index aa278d1a2..c75ff85b0 100755 --- a/EDMarketConnector.py +++ b/EDMarketConnector.py @@ -184,12 +184,6 @@ '--killswitches-file', help='Specify a custom killswitches file', ) - - parser.add_argument( - '--ttk-catalog', - help='Replace plugins with a catalog of Ttk widgets', - action='store_true', - ) ########################################################################### args: argparse.Namespace = parser.parse_args() @@ -226,9 +220,6 @@ if args.eddn_tracking_ui: config.set_eddn_tracking_ui() - if args.ttk_catalog: - config.set_ttk_catalog() - if args.force_edmc_protocol: if sys.platform == 'win32': config.set_auth_force_edmc_protocol() diff --git a/config/__init__.py b/config/__init__.py index 9adf79304..1a0ae24ae 100644 --- a/config/__init__.py +++ b/config/__init__.py @@ -202,7 +202,6 @@ class AbstractConfig(abc.ABC): __auth_force_edmc_protocol = False # Should we force edmc:// protocol ? __eddn_url = None # Non-default EDDN URL __eddn_tracking_ui = False # Show EDDN tracking UI ? - __ttk_catalog = False # Load Ttk catalog plugin ? def __init__(self) -> None: self.home_path = pathlib.Path.home() @@ -246,19 +245,6 @@ def auth_force_edmc_protocol(self) -> bool: """ return self.__auth_force_edmc_protocol - def set_ttk_catalog(self): - """Set flag to load the Ttk widget catalog plugin.""" - self.__ttk_catalog = True - - @property - def ttk_catalog(self) -> bool: - """ - Determine if the Ttk widget catalog plugin is loaded. - - :return: bool - Should the Ttk catalog plugin be loaded? - """ - return self.__ttk_catalog - def set_eddn_url(self, eddn_url: str): """Set the specified eddn URL.""" self.__eddn_url = eddn_url diff --git a/plugins/_ttk_catalog.py b/docs/examples/ttk_catalog/load.py similarity index 98% rename from plugins/_ttk_catalog.py rename to docs/examples/ttk_catalog/load.py index ed7dae3bb..42e24a185 100644 --- a/plugins/_ttk_catalog.py +++ b/docs/examples/ttk_catalog/load.py @@ -7,12 +7,16 @@ Based on https://github.com/rdbende/Azure-ttk-theme/blob/main/example.py """ +import logging +import os import tkinter as tk from tkinter import ttk -from EDMCLogging import get_main_logger +from constants import appname -logger = get_main_logger() +plugin_name = os.path.basename(os.path.dirname(__file__)) + +logger = logging.getLogger(f"{appname}.{plugin_name}") class Catalog(ttk.Frame): @@ -291,7 +295,7 @@ def setup_widgets(self): def plugin_start3(path: str) -> str: - return 'TtkCatalog' + return plugin_name plugin_app = Catalog diff --git a/plug.py b/plug.py index 162d756a4..bd98f2bbd 100644 --- a/plug.py +++ b/plug.py @@ -162,11 +162,8 @@ def load_plugins(master: tk.Tk) -> None: # Add plugin folder to load path so packages can be loaded from plugin folder sys.path.append(config.plugin_dir) - if config.ttk_catalog: - PLUGINS.append(_load_ttk_catalog_plugin()) - else: - found = _load_found_plugins() - PLUGINS.extend(sorted(found, key=lambda p: operator.attrgetter('name')(p).lower())) + found = _load_found_plugins() + PLUGINS.extend(sorted(found, key=lambda p: operator.attrgetter('name')(p).lower())) def _load_internal_plugins(): @@ -182,15 +179,6 @@ def _load_internal_plugins(): return internal -def _load_ttk_catalog_plugin(): - try: - plugin = Plugin('ttk_catalog', os.path.join(config.internal_plugin_dir_path, '_ttk_catalog.py'), logger) - plugin.folder = None - return plugin - except Exception: - logger.exception(f'Failure loading internal Plugin "ttk_catalog"') - - def _load_found_plugins(): found = [] # Load any plugins that are also packages first, but note it's *still*