Add a splash screen prior full start up in native mode #2442
Replies: 4 comments 4 replies
-
Would something like #2429 (comment) work for you? |
Beta Was this translation helpful? Give feedback.
-
I notice that the pywebview has provide a splash screen method |
Beta Was this translation helpful? Give feedback.
-
Would something like this be helpful? I use this when I want to block the UI during long-running operations: @ui.page('/')
async def index():
async def slow():
overlay.set_visibility(True)
await asyncio.sleep(5)
overlay.set_visibility(False)
ui.label('something obscured in the background')
# Decorate this element as needed:
with ui.element('div').style(('position: fixed; display: block; width: 100%; height: 100%;'
'top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0,0,0,0.5);'
'z-index: 2; cursor: pointer;')) as overlay:
with ui.element('div').classes("h-screen flex items-center justify-center"):
ui.label('Please be patient!').style(
"font-size: 50px; color: white;")
app.on_connect(slow)
ui.run() |
Beta Was this translation helpful? Give feedback.
-
@brnjak-dominik this worked for me, this is for my own native app. let me know if this works, main.py from nicegui import ui, app
from app.startup import startup
try:
import pyi_splash
except ImportError:
pyi_splash = None
app.on_startup(startup)
# Close the splash screen after the startup function is called
@app.on_startup
def close_splash():
if pyi_splash and pyi_splash.is_alive():
pyi_splash.close()
@app.on_shutdown
def shutdown():
print("Shutting down the server...")
app.shutdown()
ui.run(native=True, reload=False, port=8080, title="Label Printer", favicon="🏷️") |
Beta Was this translation helpful? Give feedback.
-
Hello guys,
first of all huge thanks to the NiceGUI Team - never enjoyed building applications this much! You guys nailed it with FastAPI and features like cpu/io bound stuff ... makes my life so much easier!
I am more on the backend side of things - but as i am building a application for different API-Requests I searched for a possibility to add an GIF/JPG/PNG as a splash screen while the application is loading.
Research led me right to the pyinstaller feature "pyi_splash" - but as of now the picture stays in the front untli the application is closed.
Have no control over the loading screen - plus it is not possible to show a GIF for example.
It would be more convenient to have control within the application, like PyQt5.
So in ui.run() - would it be possible to do something like this:
Thanks again for all of your work!
Beta Was this translation helpful? Give feedback.
All reactions