Multiselect widget

I noticed that the Multiselect widget does not contain an “index” parameter like some of the other widgets. Why is that the case? I am asking the question because I am having problems with this type of widget after my code runs the first time. For example, after making selections from the options available within the Multiselect widget, my code reruns properly and displays the correct results within the browser, but the Multiselect widget, which is located within the sidebar, goes back to displaying the "default’’ options for that widget. In general, the data now displayed within the browser no longer agrees to the widget selections displayed in the Multiselect widget within the sidebar. What could be causing this issue?

Hey @Jacob_Dykstra,

Could this be related to this issue.
Answering your first question regarding index parameter, with st.multiselect() you have the default parameter which it does almost the same as index parameter

Thanks for your response. However, I am actually using the “default” parameter currently in my code with the Multiselect widget. However, when the code reruns after a user changes one of the widgets selections, the Multiselect widget in the sidebar goes back to displaying the “defaults”, but the data displayed on the screen does not match the “default” Multiselect widget selections. Based on this behavior and based on reading some of the other posts on this website, I am wondering if this issue is related to “session state.” Could this be the cause of the issue?

After more testing I am fairly confident this issue is related to SessionState and the Streamlit sidebar. The widget works as expected when it is not included in the sidebar.

Hi @Jacob_Dykstra,

Could you provide sample code so we can reproduce the issue?

Jonathan,

Thanks for the email. I put together a small example of my code last night, but the Multiselect widget buttons are actually working within the example. So, I am thinking I must have a problem within the code on my larger project.

If I am able to eventually recreate the problem, I will follow-up with you and send you the code.

Sorry for the potential false alarm!

Thank you,

Jake

1 Like