I am not sure if you know when the dialog is close.
If thing the best is to add a second st.button().
You can “hide” it inside the dialog
st.session_state.user_input = st.text_input("Enter your input:", "")
if st.button("Run job"):
st.session_state.dialog_step = 1
if 'dialog_step' not in st.session_state:
st.session_state.dialog_step = 0
# Dialog function to show the first dialog
@st.experimental_dialog("Task Progress", width="small")
def show_progress_dialog():
st.write("Received: " + st.session_state.user_input)
if st.button("Next"):
st.session_state.dialog_step = 2
st.rerun()
# Dialog function to show the second dialog
@st.experimental_dialog("Task Progress", width="small")
def show_progress_dialog2():
st.write("⏳ Thanks for waiting!")
if st.button("Close"):
st.session_state.dialog_step = 3 # Or reset to 1 if you want to start over
st.rerun()
# Show dialogs based on the current step
if st.session_state.dialog_step == 1:
show_progress_dialog()
elif st.session_state.dialog_step == 2:
show_progress_dialog2()
Thanks for the solution, but I’m not too sure where the async task will fall in here. If I place it within “Next”, it will not trigger if the user exits the dialog without clicking next.
If I place it before the “Next” button, it will run and wait for the task to complete, before “Next” can be clicked.
In fact, the users should not need to click a “Next” button as I intend it to be a notification, not a step to be completed.
The reason why I want to make it a dialog is because a st.toast is too small and easily missed by my users, and they will ask me “why is it not running?”
At first, I have already a st.progress() running, and also have tried using stqdm as well. The issue is that my page is quite long, and the user won’t really scroll to the progress bar portion.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.