I am seeing some odd behavior with the multiselect widget that seems to be related to the delay it takes our data to load. You lose the selected values after selecting an item. I have recreated the issue using some static data and a small app (code below). If you move the multiselect above the load_data routine it behaves as expected (the majority of the time).
import streamlit as st
@st.cache()
def load_data():
data = [True]*50000
return data
a_widget = st.empty()
data_pd = load_data()
a_widget.multiselect("Apple", ['a','b','c'], key='key_apple')
Sure. When designing the application it is nice to separate the layout from the control. To do this nicely I was using the st.empty() construct. Not sure if there is another way to accomplish the same idea.
I want to define the location for the multiselect in a layout section and then set the values after loading the data and filtering based upon other input fields.
I noticed the same when not using the st.empty() as well. We are able to manage but it makes the flow of the application much more difficult to keep organized.
Oh, I think this year they are going to come up with more features so we can customize the placement of objects. And you are right, st.empty() would be the way to go for separating the layout. I have used it before, although not with multi-select, so I’m not sure why it’s not working.
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.