When filtering the select box, I get as return all the options that contains the letters “A” + “B” in order, no matter what letters we have in the middle. So, the result is something like this:
When instead I would like to receive as return only “ABB” and “ABC”. Basically, I need the filter to treat the user input as chain and not as individual letters. Is there any way to change that behavior? I checked the documentation and the forum, but found nothing.
I shared my code at the beginning. Let’s make it an app:
import streamlit as st
values = [“ABC”, “ACB”, “ABB”, “BAB”, “CAB”]
options = st.sidebar.selectbox(“Name”, values)
When I type “AB” i get as return all the values that contains “A” and then “B”, no matter where they are placed. I need the code to give me just the values what STARTS with “AB” (only “ABC” and “ABB”)
Hi @georgi, I’m not sure if what you require is possible. st.selectbox has an on_change callback that is only triggered after the change to the selectbox is made, and not while it is being changed; hence, you would not be able to use something such as .startswith() to incrementally filter what you type in your selectbox, as you type it.
Nevertheless, let’s hope a more knowledgeable person comes along with a solution; meanwhile, you could petition Streamlit for this feature.
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.