WineBarrels-WineStarter/winestarter/__main__.py

48 lines
1.2 KiB
Python

from . import gui
import asyncio
import argparse
import threading
LOOP = asyncio.get_event_loop()
# Args parse
parser = argparse.ArgumentParser(description="Wine Starter")
parser.add_argument("--config", "-c", dest="configs", type=str,
action="append", nargs=1, help="Configuration to make software runable.")
parser.add_argument("--not-run", nargs="?", const=True,
default=False, help="Doesn't start software directly.")
parser.add_argument("start", type=str, nargs="?",
const=None, help="Instance to run.")
args = parser.parse_args()
print(repr(args))
# Run gui and asyncio
_terminate = threading.Lock()
_terminate.acquire()
async def _run_async():
# Wait for gui thread init
while not _terminate.acquire(blocking=False):
await asyncio.sleep(0)
# Set main window
# Wait for async ends
while not _terminate.acquire(blocking=False):
await asyncio.sleep(0.1)
def _run_gui():
def inited_func():
_terminate.release()
gui.run_gui(inited=inited_func, configs=list(
map(lambda x: x[0], args.configs)))
_terminate.release()
threading.Thread(target=_run_gui).start()
LOOP.run_until_complete(_run_async())