Browse Source

avoid reload confirmation dialog by overriding confirm() function

Falko Schindler 4 years ago
parent
commit
896ff85677
2 changed files with 3 additions and 4 deletions
  1. 1 4
      Dockerfile
  2. 2 0
      nice_gui/nice_gui.py

+ 1 - 4
Dockerfile

@@ -13,7 +13,4 @@ WORKDIR /app
 COPY ./pyproject.toml ./poetry.lock* main.py ./
 RUN poetry install --no-root
 
-# do not show reload warning popup (see https://github.com/elimintz/justpy/issues/236#issuecomment-799431208)
-RUN sed -i "s/confirm('Page needs to be reloaded, click OK to reload')/true/g" /usr/local/lib/python3.9/site-packages/justpy/templates/main.html
-
-CMD uvicorn --reload --host 0.0.0.0 --port 80 main:ui
+CMD uvicorn --reload --host 0.0.0.0 --port 80 main:ui

+ 2 - 0
nice_gui/nice_gui.py

@@ -11,6 +11,8 @@ from matplotlib import pyplot as plt
 from .utils import handle_exceptions, provide_arguments
 
 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
+
 main = jp.Div(a=wp, classes='q-ma-md column items-start', style='row-gap: 1em')
 main.add_page(wp)
 jp.justpy(lambda: wp, start_server=False)