I am runing streamlit locally.
I have generated a text box by st.text_input(“Recommended Aerobic SRT, days”, value=“{:.2f}”.format(5), disabled=True, key=‘recommended_srt’,). Now I want to change its value from 5 to 7. How to do it by python code?
Hi,
You should put some context. We don’t know what are you trying to accomplish.
Do you want to change in the code or do you want the user to change the value or you want to update after an action ?
Case 1:
st.text_input('Recommended Aerobic SRT, days', value='{:.2f}'.format(7), disabled=True,
key='recommended_srt', )
Case 2:
st.text_input('Recommended Aerobic SRT, days', value='{:.2f}'.format(5),
key='recommended_srt', )
Case 3:
srt_value = st.session_state.get('srt_value', 5)
st.text_input('Recommended Aerobic SRT, days', value='{:.2f}'.format(srt_value), disabled=True,
key='recommended_srt', )
if st.button('update'): # Any condition to update the value
st.session_state['srt_value']= 7
st.rerun()
Thank you so much. Sorry for confusing. Case 3 is what I want. it works. Thanks again.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.