Invoking another st.button

Buttons don’t have a persistent state. They will return True immediately after clicking them, but go back to False if the user interacts with anything else. So upon clicking a button within your movie_name function, your page will reload with st.button('Show Recommendations') being false and it will look like the first page load.

You can either use a checkbox so that there is some retained state, or you can use session state to keep a memory of your button clicks.

Here’s an example creating some memory for the outer button. You can do the same for more nested buttons as needed.

# Initialize some state for showing recommendations
if 'show_recommendation' not in st.session_state:
    st.session_state.show_recommendation = False

# Callback function to make sure the state changes with each button click
def change_show():
    st.session_state.show_recommendation = not st.session_state.show_recommendation

# Independent button, with attached callback function
st.button('Show Recommendations', on_click=change_show)

# Conditional called on the key stored in session state instead of directly on the button value
if st.session_state.show_recommendation:
    st.write('Movie recommendations showing here')
    st.button('Another button here')

Here’s some helpful links: