Hi everyone ! First thanks for the streamlit package that is very useful !
I just face a problem when I develop my streamlit application with the st.button.
I explain :
I get some “filters” that the user can apply as his choice. The first filter is the tab selecting (three tabs which provide differents data).
When the user chooses a tab, then he can choose some filters. But with the st.button, when the user choose another filter after the tab, the button is “restarted” and he goes back to the welcome page.
Is it possible to keep a button activate as long as another button is not selectionned ?
For illustrate it, look at this picture :
In red : the tab selection
In blue : the filters selection
When I click on a tab, I run to some visualisation but then when I click to a filter, the application restart because filter button is not keeping activate.
Thanks a lot for read me, I hope someone can help !
Buttons set their value to True only in the instant they are clicked . After that, their value goes back to False.
In your use case you would be advised to use st.radio. Radio buttons lay out vertically, so that might not suit you. So, instead use st.checkbox in multiple columns. Then set and hold the value state of the checkboxes in st.session_state.
See “multi-page-app-with-session-state” for inspiration. If you want the page to reset, then use st.experimental_rerun to run the app from the top but still preserving the set states.
I just come to you to say thanks to your answer. Like you say, I have to layout my buttons horizontally. With a little search in addition with you answer, I find a solution than can satisfy me !
So I use the radio button, but with a Widget style parameter. Just to inform you, if you apply this :