-
Notifications
You must be signed in to change notification settings - Fork 39
/
main.py
42 lines (32 loc) · 928 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import src
import multiprocessing
import sys
import os
import asyncio
from qasync import run, QEventLoop
from functools import partial
os.environ["QT_API"] = "pyside6"
async def main(event_loop):
def close_future(future, loop):
loop.call_later(10, future.cancel)
future.cancel()
future = asyncio.Future()
window = src.Window(event_loop)
if hasattr(src.App, "aboutToQuit"):
getattr(src.App, "aboutToQuit").connect(
partial(close_future, future, event_loop))
await future
if isinstance(future.result(), int):
return future.result()
return 0
if __name__ == '__main__':
# Pyinstaller fix
multiprocessing.freeze_support()
try:
loop = QEventLoop()
asyncio.set_event_loop(loop)
sys.exit(run(main(loop)))
except asyncio.exceptions.CancelledError:
sys.exit(0)