options1 = [1, 2, 3]
options2 = ["foo", "bar"]
option_central = st.selectbox("Which number do you like best?", options1)
"You selected in the central selection: ", option_central
option1_sidebar = st.sidebar.selectbox(
"Which number do you like best?", options1
)
"You selected in the sidebar:", option1_sidebar
option2_sidebar = st.sidebar.selectbox(
"Which number do you like best?", options2
)
"You selected in the sidebar:", option2_sidebar
When changing option1_sidebar the value rendered for option_central changes as well. It is as if it is somehow related to the variable which holds the list of options. If a different list/variable is used (like in option2_sidebar) the the behavior is aligned better with what I expected. Is it a bug or a feature?
Thanks, @technicalfiddles for linking to your issue, but unfortunately it was not solving my problem. Did it solve yours? If so how exactly, could you please elaborate a little?
This is somehow related to the label. If you change your code so that the strings that refer to options1 are different, this doesn’t happen. For example:
option1_sidebar = st.sidebar.selectbox(
"Which side number do you like best?", options1
)
That’s indeed solving the problem. However, this is a little un-intuitive, isn’t it? Intuitively, the caption of the selection box is meta-data of the box and should not have this side effect. Or do I miss understand something?
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.