Encoding state of input widgets in url

Hi, I have built a streamlit app which visualizes some data, based on various settings the user can make in the sidebar.
The visualization itself can be switched between different modes (I built a form of multi page app with a select box on top of the page)

Now it is often interesting to compare different views of the same filter settings with each other. The best solution for this in my current setup is to open a new browser window and to carefully set all the filter settings on the sidebar to the same values as they are in the first window. Then one can select a different mode and compare both.
Since the visualization modes can be a bit complex, I would like to avoid having one giant compare mode with two visualizations on one page.

Copying of the settings is a bit tedious, so ideally this would be encoded into the url for example, which can then be copied to get a second session with the same input widget state.

I don’t think it is possible, but maybe somebody knows a way to get something like that?

Hi,

  1. did you consider providing an option to save each scenario (of inputs) in either a text file or list?
  2. Pulling 1/more saved scenarios for a comparison?

Cheers

thanks for the fast reply.

Mhm is there an elegant way to save the current widget state in a file to be able to restore it in a new window?
Manually writing the logic to save and restore the content of 13 input elements seems a bit tedious and error prone to maintain if I forget to add a new element to the save/restore logic.

Cheers

Check if a session state array will help.

Cheers

ideally this would be encoded into the url for example

This is possible with st.experimental_get_query_params() and st.experimental_set_query_params()

See this example

@tddeb oh yes, I think this could be pretty much exactly what I had in mind :smiley:

thanks for the hint :wink:

I use it all the time with experimental_set/get_query_params. It works pretty well. If you have a multi-page app, and therefore session state, you need to pay particular attention to the interaction between the URL and the widget state from the session.

Dinesh