[Python] My modal doesn't appear after an action in Streamlit

Discussão em 'Python' iniciado por Stack, Março 6, 2025.

  1. Stack

    Stack Membro Participativo

    I have this streamline app:

    import streamlit as st

    st.title("Simulator")

    tab_names = ["tab1", "tab2"]
    tab1, tab2= st.tabs(tab_names)


    @st.dialog("Edit your relationships")
    def edit_relationships(result):
    edit_options = tuple(result)
    selection = st.selectbox(
    "Select an entity relationship",
    edit_options
    )
    st.write(f"This is a dialog {selection}")
    if st.button("Submit"):
    st.session_state.vote = 'pear'
    st.rerun()


    with tab1:
    st.write("This is the first tab")


    with tab2:
    query = st.text_input("Enter the entity", key='t2tinput')

    if st.button('send', key='t2button'):
    try:
    result = ['banana', 'apple', 'pear']
    if st.button("Edit Relationships"):
    edit_relationships(result)

    except Exception as e:
    st.error(f"Error: {e}")


    And I want that after the 'result' list is received (from an API), that a button 'Edit relationships" appear so I click on it and a modal appear. I tried this code but after clicking on 'Edit relationships', the modal doesn't appear.

    Please, could you point out what I am doing wrong?

    Continue reading...

Compartilhe esta Página