Summary
How can i place my st.button under the st.number_input while maintaining the same functionality
Steps to reproduce
Example:
Code snippet:
keys = ['pigm_bayfer_brown_645_t', 'pigm_bayfer_yellow_420']
for key in keys:
if key not in st.session_state:
st.session_state[key] = 0.0
if st.button('Reset'):
for key in keys:
st.session_state[key] = 0.0
pigm_bayfer_brown_645_t = st.number_input('Bayferrox braun 645T [kg]:', min_value=0.0, max_value=1.0,step=0.00001, format='%.7f', key="pigm_bayfer_brown_645_t")
pigm_bayfer_yellow_420 = st.number_input('Bayferrox gelb 420 [kg]:', min_value=0.0, max_value=1.0,step=0.00001, format='%.7f', key="pigm_bayfer_yellow_420")
If applicable, please provide the steps we should take to reproduce the error or specified behavior.
Expected behavior:
I want to place the Reset Button below the st.number_input
, so that I can easily reset every entry to 0.0 by simply clicking the Reset Button.
Actual behavior:
If i place the st.button(“Reset”) below the st.number_input this error gets triggered:
StreamlitAPIException : st.session_state.pigm_bayfer_brown_645_t
cannot be modified after the widget with key pigm_bayfer_brown_645_t
is instantiated.
Is it even possible to place it below the st.number_input?