fishyboteso/fishy/gui/funcs.py

55 lines
1.3 KiB
Python
Raw Normal View History

import typing
2021-05-09 07:05:51 +00:00
from tkinter import messagebox
2020-10-17 19:06:07 +00:00
from fishy.helper.config import config
if typing.TYPE_CHECKING:
from fishy.gui import GUI
class GUIFuncsMock:
def __init__(self):
...
def show_error(self, error):
...
def bot_started(self, started):
2021-05-09 09:48:35 +00:00
...
def quit(self):
...
def start_engine(self):
...
# noinspection PyProtectedMember
class GUIFuncs:
def __init__(self, gui: 'GUI'):
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
self.gui._start_button["text"] = self.gui._get_start_stop_text()
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"
self.gui.call_in_thread(func)
def quit(self):
def func():
self.gui._root.destroy()
self.gui.call_in_thread(func)
def start_engine(self):
def start_engine():
2020-10-17 19:06:07 +00:00
config.set("last_started", self.gui._engine_var.get())
2021-05-21 23:54:09 +00:00
self.gui.engines[self.gui._engine_var.get()].start()
self.gui.call_in_thread(start_engine)