diff --git a/fishy/gui/funcs.py b/fishy/gui/funcs.py index c9c03c9..9e60a30 100644 --- a/fishy/gui/funcs.py +++ b/fishy/gui/funcs.py @@ -50,5 +50,5 @@ class GUIFuncs: def start_engine(self): def start_engine(): config.set("last_started", self.gui._engine_var.get()) - self.gui.engines[self.gui._engine_var.get()][1]() + self.gui.engines[self.gui._engine_var.get()].start() self.gui.call_in_thread(start_engine) diff --git a/fishy/gui/gui.py b/fishy/gui/gui.py index 6025f84..45af6d4 100644 --- a/fishy/gui/gui.py +++ b/fishy/gui/gui.py @@ -4,6 +4,7 @@ import threading import tkinter as tk import uuid from typing import Any, Callable, Dict, Optional +from dataclasses import dataclass from ttkthemes import ThemedTk @@ -18,6 +19,12 @@ from . import main_gui from .log_config import GUIStreamHandler +@dataclass +class EngineRunner: + config: Callable + start: Callable + + class GUI: def __init__(self, get_engine: Callable[[], IEngineHandler]): self.funcs = GUIFuncs(self) @@ -58,13 +65,13 @@ class GUI: @property def engines(self): engines = { - "Semi Fisher": [lambda: config_top.start_semifisher_config(self), # start config function - self.engine.toggle_semifisher], # start engine function + "Semi Fisher": EngineRunner(lambda: config_top.start_semifisher_config(self), + self.engine.toggle_semifisher), + + "Full-Auto Fisher": EngineRunner(lambda: config_top.start_fullfisher_config(self), + self.engine.toggle_fullfisher) } - if web.has_beta(): - engines["Full-Auto Fisher"] = [lambda: config_top.start_fullfisher_config(self), - self.engine.toggle_fullfisher] return engines def create(self): diff --git a/fishy/gui/main_gui.py b/fishy/gui/main_gui.py index 9da8f49..e52f043 100644 --- a/fishy/gui/main_gui.py +++ b/fishy/gui/main_gui.py @@ -110,7 +110,8 @@ def _create(gui: 'GUI'): gui._engine_select = ttk.OptionMenu(start_frame, gui._engine_var, last_started, *labels) gui._engine_select.pack(side=tk.LEFT) - gui._config_button = ttk.Button(start_frame, text="⚙", width=0, command=lambda: engines[gui._engine_var.get()][0]()) + gui._config_button = ttk.Button(start_frame, text="⚙", width=0, + command=lambda: engines[gui._engine_var.get()].config()) gui._config_button.pack(side=tk.RIGHT) gui._start_button = ttk.Button(start_frame, text=gui._get_start_stop_text(), width=25,