2020-06-01 12:58:18 +00:00
|
|
|
import typing
|
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
from threading import Thread
|
|
|
|
from typing import Callable
|
|
|
|
|
|
|
|
if typing.TYPE_CHECKING:
|
|
|
|
from fishy.gui import GUI
|
|
|
|
|
|
|
|
|
|
|
|
class IEngine(ABC):
|
|
|
|
|
|
|
|
def __init__(self, config, gui_ref: 'Callable[[], GUI]'):
|
|
|
|
self.get_gui = gui_ref
|
|
|
|
self.start = False
|
2020-06-03 01:41:54 +00:00
|
|
|
self.window = None
|
2020-06-01 12:58:18 +00:00
|
|
|
self.thread = None
|
|
|
|
self.config = config
|
|
|
|
|
|
|
|
@property
|
|
|
|
def gui(self):
|
|
|
|
return self.get_gui().funcs
|
|
|
|
|
|
|
|
def toggle_start(self):
|
|
|
|
self.start = not self.start
|
|
|
|
if self.start:
|
|
|
|
self.thread = Thread(target=self.run)
|
|
|
|
self.thread.start()
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def run(self):
|
|
|
|
...
|