diff --git a/fishy/engine/common/event_handler.py b/fishy/engine/common/event_handler.py index 612a673..c8105a5 100644 --- a/fishy/engine/common/event_handler.py +++ b/fishy/engine/common/event_handler.py @@ -5,8 +5,29 @@ from fishy.engine import SemiFisherEngine from fishy.engine.fullautofisher.engine import FullAuto -class EngineEventHandler: +class IEngineHandler: + def __init__(self): + ... + + def start_event_handler(self): + ... + + def toggle_semifisher(self): + ... + + def toggle_fullfisher(self): + ... + + def check_pixel_val(self): + ... + + def quit(self): + ... + + +class EngineEventHandler(IEngineHandler): def __init__(self, gui_ref): + super().__init__() self.event_handler_running = True self.event = [] diff --git a/fishy/gui/config_top.py b/fishy/gui/config_top.py index 5001347..f8bc6c7 100644 --- a/fishy/gui/config_top.py +++ b/fishy/gui/config_top.py @@ -3,6 +3,7 @@ import os import typing from tkinter.filedialog import askopenfilename +from fishy.engine.common.event_handler import IEngineHandler from fishy.helper import helper from fishy import web @@ -109,3 +110,10 @@ def start_semifisher_config(gui: 'GUI'): controls_frame.pack(padx=(5, 5), pady=(5, 5)) top.start() + + +if __name__ == '__main__': + from fishy.gui import GUI + gui = GUI(lambda: IEngineHandler()) + gui.call_in_thread(lambda: start_fullfisher_config(gui)) + gui.create() diff --git a/fishy/gui/gui.py b/fishy/gui/gui.py index 79d8821..14d5f45 100644 --- a/fishy/gui/gui.py +++ b/fishy/gui/gui.py @@ -8,7 +8,7 @@ import threading from fishy.web import web from ttkthemes import ThemedTk -from fishy.engine.common.event_handler import EngineEventHandler +from fishy.engine.common.event_handler import EngineEventHandler, IEngineHandler from fishy.gui import config_top from fishy.gui.funcs import GUIFuncs from . import main_gui @@ -18,7 +18,7 @@ from ..helper.helper import wait_until class GUI: - def __init__(self, get_engine: Callable[[], EngineEventHandler]): + def __init__(self, get_engine: Callable[[], IEngineHandler]): self.funcs = GUIFuncs(self) self.get_engine = get_engine diff --git a/fishy/helper/config.py b/fishy/helper/config.py index 896fbc8..838bde3 100644 --- a/fishy/helper/config.py +++ b/fishy/helper/config.py @@ -107,7 +107,7 @@ class config: :param default: default value to return if key is not found :return: config value """ - return default if config._instance[key] is None else config._instance[key] + return default if config._instance is None or config._instance[key] is None else config._instance[key] @staticmethod def set(key, value, save=True): @@ -117,6 +117,9 @@ class config: :param value: value to save :param save: False if don't want to save right away """ + if config._instance is None: + return + config._instance[key] = value if save: config.save_config() @@ -135,4 +138,6 @@ class config: @staticmethod def save_config(): + if config._instance is None: + return config._instance.save_config()