pywebio / PyWebIO

Write interactive web app in script way.
https://pywebio.readthedocs.io
MIT License
4.49k stars 384 forks source link

Page not get inactive if there are buttons in the page #615

Closed c8tech closed 10 months ago

c8tech commented 10 months ago

When I run below code in script mode, the page won't get exited anymore:

put_button("click me", onclick=lambda: toast("Clicked"), color='success', outline=True)

This happens when I upgraded pywebio to v1.8.2 from v1.5.2

If this is a new feature designed on purpose, how would I force a script to exit gracefully?

wang0618 commented 10 months ago

It's by design. the user may want to click the button if there is any, so the app will keep active. However, in script mode, if user close the web page, the script will exit regardless of whether there are button or not

c8tech commented 10 months ago

Thanks for the prompt reply!

There is an "Exit" button in my page that user can use it to manually "kill" the process only (page is not closed as some text/log info might still be helpful). How to achive this under this new feature? I also tried to call sys.exit() instead but not work.