i want to create a button to reset the whole dashboard or reload the page.
Hey @spctr01,
Welcome to the Streamlit community!
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!
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 """
This seems to do the trick
import pyautogui
if st.button("Reset"):
pyautogui.hotkey("ctrl","F5")
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