All the below are with respect to items placed on the sidebar
I have some filters that depend on all other filters. For example, if I have a dataset for cars and car types, I want to filter by either of them and have the other’s options reduced. Here’s an example:
---- USER FLOW ----
User selects BMW. TYPES options are reduced to “SEDAN” and “COUPE” because there are no BMW trucks in this example.
User is happy
<< Here’s where it breaks down >>>
Now the user wants to go the other way around. Clears the CARS filter and selects “SEDAN”.
So the CARS dropdown should update to [’FORD’ and ‘AUDI’], but it doesn’t! It still displays all options. << Here’s where it breaks down / >>>
----- END OF USER FLOW ----
I think this happens because Streamlit compiles vertically, but, as Javascript would do, it’d be cool if it updates the options based on the actual objects’ contents.
That approach is actually on the product roadmap. When writing Streamlit we decided to first focus on the “getting started” use-case. Our goal was to make it extremely easy to build UIs, even if this meant the set of UIs you could build was actually limited. Now that Streamlit is out in the world, we’re working on expanding the use cases.
So whereas you can only do something like the following right now, where the object both writes and immediately returns the value:
x = st.slider(...)
In the future you could do something like this:
# create a slider object
slider_obj = st.Slider(...)
# edit the value of the slider
y = slider_obj.value + 10
# [do more things…]
# finally, render the slider
st.write(slider_obj)
…and, of course, we’d still support today’s API as a syntax sugar over the new object-based API.
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.