Is it possible to create a button to reset/relaod the whole dashboard

i want to create a button to reset the whole dashboard or reload the page.

Hey @spctr01,

Welcome to the Streamlit community! :partying_face:

I think you could do this by using session state, check out an instance of using session state here!

You also might be able to use an alternative as posted on the community here!

Happy Streamlit-ing! :blush:
Marisa

I found a solution, using .empty()

You can try this sample code:

import streamlit as st

#You can check .empty documentation
placeholder = st.empty()

with placeholder.container():
    st.title("Try")
    btn = st.button("try")

#If btn is pressed or True
if btn:
    #This would empty everything inside the container
    placeholder.empty()
    
   """ ENTER NEW CODE HERE """
2 Likes

This seems to do the trick

import pyautogui
 
if st.button("Reset"):
    pyautogui.hotkey("ctrl","F5")
8 Likes

Hi @InputBlackBoxOutput ,

This is so nice, never knew about this workaround. Btw, quick question, does it work for all (Windows or Mac )

Best,
Avra

StreamlitAPIException : container() is not a valid Streamlit command.

https://docs.streamlit.io/en/stable/api.html?highlight=container#streamlit.container

You should try the example I did.

-a=st.button(‘Show dashboard’, False)
-if st.button(‘Reset’,False):
----st.empty()
else:
----if a:
--------st.subheader(‘Dashboard’)
--------dashboard showing code