|
@@ -6,10 +6,14 @@ import uvicorn
|
|
|
import inspect
|
|
|
import time
|
|
|
import asyncio
|
|
|
+import os.path
|
|
|
from contextlib import contextmanager
|
|
|
from matplotlib import pyplot as plt
|
|
|
from .utils import handle_exceptions, provide_arguments
|
|
|
-from multiprocessing import Process
|
|
|
+
|
|
|
+if not inspect.stack()[-2].filename.endswith('spawn.py'):
|
|
|
+ module = os.path.splitext(os.path.basename(inspect.stack()[-1].filename))[0]
|
|
|
+ uvicorn.run(f'{module}:ui', host='0.0.0.0', port=80, lifespan='on', reload=True)
|
|
|
|
|
|
wp = jp.QuasarPage(delete_flag=False, title='Nice GUI', favicon='favicon.png')
|
|
|
wp.head_html = '<script>confirm = () => true;</script>' # HACK: avoid confirmation dialog for reload
|
|
@@ -102,10 +106,6 @@ class Ui(Starlette):
|
|
|
def startup():
|
|
|
[jp.run_task(t) for t in self.tasks]
|
|
|
|
|
|
- def run(self):
|
|
|
-
|
|
|
- uvicorn.run(self, host='0.0.0.0', port=80, lifespan='on', reload=False)
|
|
|
-
|
|
|
def label(self, text='', typography=[]):
|
|
|
|
|
|
if isinstance(typography, str):
|
|
@@ -237,3 +237,5 @@ class Ui(Starlette):
|
|
|
await asyncio.sleep(interval)
|
|
|
|
|
|
self.tasks.append((timeout() if once else loop()))
|
|
|
+
|
|
|
+ui = Ui()
|