Hello, I have encountered something I cannot make sense of and was wondering if it is a bug.
I have a button, for submitting information (not a submit button, just regular) with a help string, that changes depending on, whether the button is enabled or disabled. The code disables the button immediately upon change and I would expect it to write “submitted”. However, this is not happening. Here is a snippet:
def disable_button():
st.session_state.button_disabled = True
def button_help():
if st.session_state.get('button_disabled', False):
return "The button is disabled"
return "The button is enabled"
button = st.button(
"Get answers", type='primary',
help=button_help(),
on_click=disable_button,
disabled=st.session_state.get('button_disabled', False)),
key="my_button"
if button:
st.write("Submitted")
However, it will work, if I directly set help as a string or if I return the same string in the button_help function no matter, what. i.e. returning “The button is enabled” both when it is enabled and disabled. I also experimented with setting the key for the button, as I thought changing the help string may create an entirely new bytton.
If any of you know what causes this, please, let me know ![]()
The program is running locally and no errors are raised. I am using Python version 3.10.4 and Streamlit version 1.37.1