2020-06-25 01:22:39 +00:00
|
|
|
from tkinter import messagebox
|
|
|
|
|
|
|
|
import typing
|
2020-10-17 19:06:07 +00:00
|
|
|
|
|
|
|
from fishy.helper.config import config
|
|
|
|
|
2020-06-25 01:22:39 +00:00
|
|
|
if typing.TYPE_CHECKING:
|
|
|
|
from fishy.gui import GUI
|
2020-05-19 03:11:58 +00:00
|
|
|
|
|
|
|
|
2020-10-17 08:06:49 +00:00
|
|
|
class GUIFuncsMock:
|
|
|
|
def __init__(self):
|
|
|
|
...
|
|
|
|
|
|
|
|
def show_error(self, error):
|
|
|
|
...
|
|
|
|
|
|
|
|
def bot_started(self, started):
|
|
|
|
...
|
|
|
|
|
|
|
|
def quit(self):
|
|
|
|
...
|
|
|
|
|
|
|
|
def start_engine(self):
|
|
|
|
...
|
|
|
|
|
|
|
|
|
2020-05-19 03:11:58 +00:00
|
|
|
# noinspection PyProtectedMember
|
|
|
|
class GUIFuncs:
|
2020-06-25 01:22:39 +00:00
|
|
|
def __init__(self, gui: 'GUI'):
|
2020-05-19 03:11:58 +00:00
|
|
|
self.gui = gui
|
|
|
|
|
|
|
|
def show_error(self, error):
|
|
|
|
self.gui.call_in_thread(lambda: messagebox.showerror("ERROR", error))
|
|
|
|
|
|
|
|
def bot_started(self, started):
|
|
|
|
def func():
|
|
|
|
self.gui._bot_running = started
|
2020-06-25 01:22:39 +00:00
|
|
|
self.gui._start_button["text"] = self.gui._get_start_stop_text()
|
2020-06-25 01:56:17 +00:00
|
|
|
self.gui._engine_select["state"] = "disabled" if self.gui._bot_running else "normal"
|
|
|
|
self.gui._config_button["state"] = "disabled" if self.gui._bot_running else "normal"
|
2020-06-25 01:22:39 +00:00
|
|
|
|
|
|
|
self.gui.call_in_thread(func)
|
|
|
|
|
|
|
|
def quit(self):
|
|
|
|
def func():
|
|
|
|
self.gui._root.destroy()
|
2020-05-19 03:11:58 +00:00
|
|
|
|
|
|
|
self.gui.call_in_thread(func)
|
2020-06-25 16:39:05 +00:00
|
|
|
|
|
|
|
def start_engine(self):
|
|
|
|
def start_engine():
|
2020-10-17 19:06:07 +00:00
|
|
|
config.set("last_started", self.gui._engine_var.get())
|
2020-06-25 16:39:05 +00:00
|
|
|
self.gui.engines[self.gui._engine_var.get()][1]()
|
|
|
|
self.gui.call_in_thread(start_engine)
|