Delete widgets

Hello all,

I am using streamlit to build a web app. I need to design an interactive web-app where I need to remove(delete) a set of widgets after a button click and replace them with new ones.

Please let me know if you find a solution. Thanks in advance.

PS: Using empty() or beta_containers did not solve my issue.

Maybe you can use pythonโ€™s del operator. Will something like this work for you?

table_data = {'Column 1': [1, 2], 'Column 2': [3, 4]}

if st.button('delet dis'):
    del table_data
    st.write('mr button has delet for u')

1 Like

Thanks for creating the sandbox @sjd333! :smiley: Itโ€™s awesome to be able to try something out quickly in the browser! :clap:

is it possible to delete a button after click this button ?

sovled by using st.empty(), but if there is a better way ?

placeholder = st.empty()
isclick = placeholder.button('delete this button')
if isclick:

Thank you so much @jackie_xiao, this helped me a lot.

@Harish_Kodarapu have you found answer to the given problemโ€ฆ I want to delete a Folium map on the click of a buttonโ€ฆ Can you help me if this issue is solved for you?