I have a form where the user picks some events to cancel, they pick rows from a dataframe, click the cancel button and then an st.dialog appears asking to confirm.
but for some reason the dialog window closes almost instantly after being opened without throwing a single error, at least that i can find, and even weirder is that this code is 90% copy pasted from another page i made where you cancel a different type of event and it works fine
broken code snippets:
if not st.user.is_logged_in:
st.stop()
if 'erro_db' not in st.session_state:
st.session_state['erro_db'] = False
pc = is_pc()
@st.dialog("Confirma o cancelamento?")
def confirmation_window():
confirmacao = st.columns(2)
with confirmacao[0]:
if st.button("Sim", type="primary"):
cancelar() #cancel doesnt run since i dont even have time to click the button
st.rerun()
with confirmacao[1]:
if st.button("Não", type="primary"):
st.rerun()
selecionados = calen.selection.rows
if st.button("Cancelar reservas", type="primary"):
if selecionados == []:
st.error("Nenhuma reserva selecionada")
else:
reservas_formadores = ler_reservas_formadores(True)
formadores = ler_formadores(True) #reset cache, no streamlit command is used
confirmation_window()
code from another file that works:
if not st.user.is_logged_in:
st.stop()
if 'erro_db' not in st.session_state:
st.session_state['erro_db'] = False
pc = is_pc()
@st.dialog("Confirma o cancelamento?")
def confirmation_window():
confirmacao = st.columns(2)
with confirmacao[0]:
if st.button("Sim", type="primary"):
cancelar()
st.rerun()
with confirmacao[1]:
if st.button("Não", type="primary"):
st.rerun()
selecionados = calen.selection.rows
if st.session_state['erro_db']:
st.error("Erro na modificação. Alterações podem não ter sido realizadas.")
if st.button("Cancelar reservas", type="primary"):
if selecionados == []:
st.error("Nenhuma
reserva selecionada")
else:
reservas_salas = ler_reservas_salas(True)
salas = ler_salas(True)
confirmation_window()