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.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.