How to automatically close open web pages #4205
-
Question
import asyncio
from nicegui import ui, app
async def countdown_timer(initial_time=0.5):
total_seconds = initial_time * 60
while total_seconds >= 0:
minutes, seconds = divmod(int(total_seconds), 60)
timer_label.text = f'{minutes:02}:{seconds:02}'
if total_seconds <= 0:
app.shutdown()
await asyncio.sleep(1)
total_seconds -= 1
timer_label = ui.label(f'{0.5}').style('font-size: 20px;')
ui.timer(1, countdown_timer)
ui.run(reload=False, port=8081) |
Beta Was this translation helpful? Give feedback.
Answered by
falkoschindler
Jan 13, 2025
Replies: 1 comment 6 replies
-
What do you mean with exit function? What should happen? Should the browser show another page? Or show a message? |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Maybe you need a short delay between calling
ui.run_javascript
andapp.shutdown
. Otherwise the JavaScript command is still in the outbox when the app shuts down.