Hello everyone, greetings from Brazil, I have a problem with “st.session_state”, in which I need to execute the action twice for it to be executed, I’m using “on_change” and even so it only works after incrementing and running it for the second time turn. I apologize if it was a little confusing, my English isn’t that good.
with col2:
def cid_change():
st.session_state.cid_change = True
st.rerun()
container = st.container()
for key, value in st.session_state.df.items():
if key == "CID":
st.session_state.inputs[key] = st.text_input(key, value.upper(), on_change=cid_change).upper()
if st.session_state.cid_change:
temp_motivo = cid_query(st.session_state.inputs["CID"])
st.session_state.inputs["Motivo do Afastamento"] = temp_motivo
st.session_state.df = st.session_state.inputs
st.session_state.cid_change = False
else:
st.session_state.inputs[key] = st.text_input(key, value)