Ugliness is in the eye of the beholder. Just showing us a picture and saying “it is ugly” does not tell us what you want or what problem you are trying to solve.
Maybe the problem is that you are creating a form with only a submit button in it.
Hi,
thanks for answer. here the catch, you don’t assign new variables (like form.option_annotator and etc) instead you use st.session_state.<with key world>. I didn’t know that, and, yes from docs its not really clear. Thanks again.
Glad it helped. That’s why I linked the docs: st.form - Streamlit Docs
In the examples, they never assign new veriables as members of the st.form object. Actually, this is never the case for any streamlit widget.
But if I want use variables immediately after that was selected and show what user selected before submit st.write(f'selected {my_var}') it doesn’t work. And if it will work in continue, in next function, whcih I define before?
You are unable to use a variable immediately after selection if it is inside the form. Per the docs for forms, widget values inside a form won’t be processed until the form itself is submitted.
A useful way to understand this interaction is to include st.write(st.session_state) at the start of your app and watch how the session_state changes as you move through your app.
One interesting thing to note is that any change to session_state prior to submitting your form will cause the default values inside the form to be added to session_state, but they will not change until the form is submitted. Conversely, if you submit your form without interacting with the checkbox, it’s default value will also be added to session_state without any interaction.
See @Wally 's code below with a checkbox and writing the session_state to the app added.