Unexpected session_state behaviour

I had a similar issue, see here Callbacks - how to get current control value? - Using Streamlit - Streamlit
Setting the value by the value argument to number_input etc via session_state does not work.Rather define a key for the widget and set the intial value with some constant. If you use the key parameter, an entry for the widget is automatically created in the session_state dict. If you need to modify the value after the user has entered something, use a callback.
I gues one problem in general is that while the streamlit code looks like normal python, the actual operation is determined by the streamlit engine and can be quite different to what the user expects.

4 Likes