Hello,
I’m using the new query_params, but it seems to be adding the keys one by one. That results in having to press the back button of the browser twice for going back to the previous page.
My code:
import streamlit as st
my_dict = dict()
my_dict['page'] = 'hello'
my_dict['bla'] = 'aha'
if st.button('test'):
st.query_params.update(my_dict)
after pressing the test button, check the back button behavior of your browser.
I’ve also tried setting st.query_params twice, one for each key. Same result. Is there any way to prevent/fix this behavior?
Note that st.query_params inherits its update method from collections.abc.MutableMapping:
>>> type(st.query_params).update
<function MutableMapping.update at 0x7e5afcc02e80>
>>> help(type(st.query_params).update)
Help on function update in module collections.abc:
update(self, other=(), /, **kwds)
D.update([E, ]**F) -> None. Update D from mapping/iterable E and F.
If E present and has a .keys() method, does: for k in E: D[k] = E[k]
If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v
In either case, this is followed by: for k, v in F.items(): D[k] = v
It’s somewhat weird that that was decided inbetween the experimental phase with st.experimental_set_query_params() and the actual launch. I hope it can be fixed. I’ve suggested a from_dict() function with an optional parameter for full replacement or merging.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.