close splash when gui finishes loading

hide fishy window until its ready to show
draw splash screen above fishy window
This commit is contained in:
Adam Saudagar 2022-02-03 01:06:41 +05:30
parent 4ea27ae7da
commit 17c014d690
4 changed files with 28 additions and 8 deletions

View File

@ -70,7 +70,7 @@ def initialize(window_to_hide):
def main():
active.init()
config.init()
splash.start()
finish_splash = splash.start()
hotkey.init()
print("launching please wait...")
@ -86,7 +86,7 @@ def main():
return
bot = EngineEventHandler(lambda: gui_window)
gui_window = GUI(lambda: bot)
gui_window = GUI(lambda: bot, finish_splash)
hotkey.start()
@ -96,7 +96,8 @@ def main():
gui_window.start()
active.start()
bot.start_event_handler()
bot.start_event_handler() # main thread loop
config.stop()
hotkey.stop()
active.stop()

View File

@ -25,9 +25,10 @@ class EngineRunner:
class GUI:
def __init__(self, get_engine: Callable[[], IEngineHandler]):
def __init__(self, get_engine: Callable[[], IEngineHandler], on_ready: Callable):
self.funcs = GUIFuncs(self)
self.get_engine = get_engine
self.on_ready = on_ready
self.config = config
self._start_restart = False

View File

@ -31,6 +31,7 @@ def _create(gui: 'GUI'):
engines = gui.engines
gui._root = ThemedTk(theme="equilux", background=True)
gui._root.attributes('-alpha', 0.0)
gui._root.title("Fishybot for Elder Scrolls Online")
gui._root.iconbitmap(helper.manifest_file('icon.ico'))
@ -138,6 +139,9 @@ def _create(gui: 'GUI'):
gui._root.protocol("WM_DELETE_WINDOW", set_destroy)
gui._destroyed = False
gui._root.update()
gui.on_ready()
gui._root.after(0, gui._root.attributes, "-alpha", 1.0)
while True:
gui._root.update()

View File

@ -1,6 +1,7 @@
import logging
import time
import tkinter as tk
from multiprocessing import Process
from multiprocessing import Process, Queue
from PIL import Image, ImageTk
@ -8,12 +9,14 @@ from fishy.helper import helper
from fishy.helper.config import config
def show(win_loc):
def show(win_loc, q):
logging.debug("started splash process")
dim = (300, 200)
top = tk.Tk()
top.overrideredirect(True)
top.lift()
top.attributes('-topmost', True)
top.title("Loading...")
top.resizable(False, False)
@ -32,9 +35,20 @@ def show(win_loc):
top.geometry("{}x{}+{}+{}".format(dim[0], dim[1], int(loc[0]) + int(dim[0] / 2), int(loc[1]) + int(dim[1] / 2)))
top.update()
time.sleep(3)
q.get()
time.sleep(0.2)
top.destroy()
logging.debug("ended splash process")
def create_finish(q):
def finish():
q.put("stop")
return finish
def start():
Process(target=show, args=(config.get("win_loc"),)).start()
q = Queue()
Process(target=show, args=(config.get("win_loc"), q,)).start()
return create_finish(q)