(Beginner) st.button

Hi im still a beginner in using streamlit and even to program somthing i just started. sombody can help me how i can programm a button, when i am click it, the button dissapears and a new button will pop up?

with help from chatGPT i did this but the first button is not dissapearing after klicking.

import streamlit as st

if ‘button_clicked’ not in st.session_state:
if st.button(“Click here”):
st.session_state.button_clicked = True

if st.session_state.get(‘button_clicked’, False):
if st.button(“Can u please click the button?”):
st.session_state.second_button_clicked = True

Hey @kd1339584,

Thanks for sharing this question!

You can do this using st.empty():

import streamlit as st

placeholder = st.empty()

button = placeholder.button("Click me")

if button:
    placeholder.button("New button")

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.