2022-02-02 19:36:41 +00:00
|
|
|
import logging
|
2020-10-13 13:49:39 +00:00
|
|
|
import time
|
2021-05-09 06:32:36 +00:00
|
|
|
import tkinter as tk
|
2022-02-02 19:36:41 +00:00
|
|
|
from multiprocessing import Process, Queue
|
2021-05-09 07:05:51 +00:00
|
|
|
|
2020-10-13 13:49:39 +00:00
|
|
|
from PIL import Image, ImageTk
|
|
|
|
|
|
|
|
from fishy.helper import helper
|
2021-05-09 07:05:51 +00:00
|
|
|
from fishy.helper.config import config
|
2020-10-13 13:49:39 +00:00
|
|
|
|
|
|
|
|
2022-02-02 19:36:41 +00:00
|
|
|
def show(win_loc, q):
|
|
|
|
logging.debug("started splash process")
|
2021-05-09 09:09:26 +00:00
|
|
|
dim = (300, 200)
|
2021-05-09 06:32:36 +00:00
|
|
|
top = tk.Tk()
|
2020-10-13 13:49:39 +00:00
|
|
|
|
2021-02-14 11:03:39 +00:00
|
|
|
top.overrideredirect(True)
|
|
|
|
top.lift()
|
2022-02-02 19:36:41 +00:00
|
|
|
top.attributes('-topmost', True)
|
2020-10-13 13:49:39 +00:00
|
|
|
|
|
|
|
top.title("Loading...")
|
|
|
|
top.resizable(False, False)
|
|
|
|
top.iconbitmap(helper.manifest_file('icon.ico'))
|
|
|
|
|
2021-05-09 06:32:36 +00:00
|
|
|
canvas = tk.Canvas(top, width=dim[0], height=dim[1], bg='white')
|
2020-10-13 13:49:39 +00:00
|
|
|
canvas.pack()
|
2021-02-14 11:03:39 +00:00
|
|
|
top.image = Image.open(helper.manifest_file('fishybot_logo.png')).resize(dim)
|
2020-10-13 13:49:39 +00:00
|
|
|
top.image = ImageTk.PhotoImage(top.image)
|
2021-05-09 06:32:36 +00:00
|
|
|
canvas.create_image(0, 0, anchor=tk.NW, image=top.image)
|
2020-10-13 13:49:39 +00:00
|
|
|
|
2021-02-14 11:03:39 +00:00
|
|
|
# Position splash at the center of the main window
|
2021-03-29 10:31:12 +00:00
|
|
|
|
2021-05-09 09:09:26 +00:00
|
|
|
default_loc = (str(top.winfo_reqwidth()) + "+" + str(top.winfo_reqheight()) + "+" + "0" + "0")
|
2021-03-29 10:31:12 +00:00
|
|
|
loc = (win_loc or default_loc).split("+")[1:]
|
2021-05-09 09:09:26 +00:00
|
|
|
top.geometry("{}x{}+{}+{}".format(dim[0], dim[1], int(loc[0]) + int(dim[0] / 2), int(loc[1]) + int(dim[1] / 2)))
|
2021-02-14 11:03:39 +00:00
|
|
|
|
2020-10-13 13:49:39 +00:00
|
|
|
top.update()
|
2022-02-02 19:36:41 +00:00
|
|
|
q.get()
|
|
|
|
time.sleep(0.2)
|
2020-10-13 13:49:39 +00:00
|
|
|
top.destroy()
|
2022-02-02 19:36:41 +00:00
|
|
|
logging.debug("ended splash process")
|
|
|
|
|
|
|
|
|
|
|
|
def create_finish(q):
|
|
|
|
def finish():
|
|
|
|
q.put("stop")
|
|
|
|
|
|
|
|
return finish
|
2020-10-13 13:49:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
def start():
|
2022-02-02 19:36:41 +00:00
|
|
|
q = Queue()
|
|
|
|
Process(target=show, args=(config.get("win_loc"), q,)).start()
|
|
|
|
return create_finish(q)
|