Hi,
Is there any functionality with which I can close the streamlit app (browser tab, command prompt) when a button is clicked.
Best,
Debayan
Hi,
Is there any functionality with which I can close the streamlit app (browser tab, command prompt) when a button is clicked.
Best,
Debayan
Hi @DebayanPaul93, I don’t think this functionality has been built in as yet. A Streamlit insider can opine further.
Cheers
Hi,
anyone with a solution/work-around?
Your issue has been asked about before. Ref Terminating Streamlit server from within the code · Issue #668 · streamlit/streamlit · GitHub.
You could probably try to close the window with Selenium.
Cheers
You can try this:
import streamlit as st
import time
import keyboard
import os
import psutil
exit_app = st.sidebar.button("Shut Down")
if exit_app:
# Give a bit of delay for user experience
time.sleep(5)
# Close streamlit browser tab
keyboard.press_and_release('ctrl+w')
# Terminate streamlit python process
pid = os.getpid()
p = psutil.Process(pid)
p.terminate()
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.