Experimental set_query_params and get_query_params issue

Hi all,

The experimental get and set query params introduced in Streamlit version 0.65.0 would be incredibly useful in a project of mine. But I have troubles using it properly. I want to be able to use it as in the demo, i.e. to both set default parameters through a query string, and to update the query string when widget values change in order to bookmark the application state.

But even using the example from the demo I get the issue, that the interaction between set and get query parameters creates problems. The radio buttons in the example requires two clicks every time to make a switch. Below is a minimal example - I am using version 0.66.0.

import streamlit as st

radio_list = ['Eat', 'Sleep', 'Both']
query_params = st.experimental_get_query_params()

default = int(query_params["activity"][0]) if "activity" in query_params else 0
activity = st.radio(
    "What are you doing at home during quarantine?",
    radio_list,
    index = default
)

st.experimental_set_query_params(activity=radio_list.index(activity))
            

Would greatly appreciate any input on how to make this work :slight_smile:

Sorry! I found that this discussion is already in the GitHub pull request . I will try the solution out and mark this thread as solved if it solves my problem.

3 Likes

I found a solution to my problems which includes some functionality for setting values which I think deserves its own thread.