Combining session state with callback and checkbox inside forms

Hi Folks,

Following the example on the official blog, I am trying to combine session state with callbacks. However, I would like to add a checkbox inside the form. You can see the entire code below.

What happens is the following:
(1) the first time I hit the st.form_submit_button, the slider appear but state of st.session_state.price does not change.
(2) second time, it works as expected by changing the state of price.

I have tried different things but it seems like it has to do with the way session state need to be initialized.

What I need for my use case is to include two or more chechbox widgets inside the form which represent two conditions to filter out the data.
So that a users can hit either any or both of chechboxes.

I am using streamlit 0.84.2

Is there any turnaround for a similar issue?
Thanks in advance!

OK, I have fund a solution by introducing a state even for the checkbox.
It is kind of dirty, so for sure it should be a better solution in a more ‘streamlit’ way!

1 Like

Happy to see you found a workaround oltipreka! :raised_hands:

Happy Streamlitin’! :balloon:


Oh thanks, but I am still not satisfied.
There should be some other cleaner solutions. :slight_smile: