Hello, I am using st.dialog. I want to start a function after user closed the dialog. Is that possible? Thanks. Best regards. Gerhard
Here’s a simple example
import streamlit as st
PROBLEM = """Hello, I am using st.dialog. I want to start a function after user closed the dialog. Is that possible? Thanks. Best regards. Gerhard"""
if "num_runs" not in st.session_state:
st.session_state["num_runs"] = 0
def my_function():
st.session_state["num_runs"] += 1
@st.experimental_dialog("my_dialog")
def my_dialog():
if st.button("Close"):
my_function()
st.rerun()
if st.button("Open Dialog"):
my_dialog()
st.write("Num runs:", st.session_state["num_runs"])
Thanks. If user uses the cross in the right corner of dialog, st.button(„Close“) does nothing.
Perhaps I did not understand it correctly.
Best regards Gerhard
That’s correct, clicking the X or hitting escape does close the dialog, but cannot trigger another function.
Is it possible to see in Python if the dialog is open?
No, not including if it’s closed by clicking the X
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.