🧑‍💻 Get window in backend

This commit is contained in:
zhbaor 2023-03-05 00:17:20 +08:00
parent cfb0337c69
commit fe36735f37
3 changed files with 8 additions and 26 deletions

20
main.py
View file

@ -4,33 +4,17 @@ import webview
import platform
from os import _exit
from time import sleep
from backend import app, action_queue, path_queue
def select_download_path(window):
while True:
path = action_queue.get()
result = window.create_file_dialog(webview.FOLDER_DIALOG)
if result:
path_queue.put(result[0])
else:
path_queue.put(path)
def on_closed():
sleep(1)
_exit(0)
from backend import app
if __name__ == "__main__":
window = webview.create_window(
"badl - BiliBili Audio Downloader", app, width=500, height=700
)
window.events.closed += on_closed
if os := platform.system() == "Linux":
gui = "gtk"
elif os == "Windows":
gui = "edgehtml"
else:
gui = ""
webview.start(gui=gui, func=select_download_path, args=(window,))
webview.start(gui=gui)