Hello - I am using variables to display information in my sidebar. The variables are called out of st.session_state, and everything seems to run smoothly initially.
I also have a button in the sidebar that changes the variables stored in the st.session_state. When I click the button everything displayed in the main page updates, but the variables in the side bar do not. I have to click a radio button (also in the sidebar) to force it to refresh itself. After I do this, the variables in the side bar do update appropriately.
Any idea what is going on here? In my code, the commands to display the variables in the sidebar do appear before the code for the button, but I don’t think that should matter.
Thanks very much
Edit I put the code that effects the state into a call back function that the button now calls, with the intent that this code would run before the page is re-run. No change in functionality from what I describe above.
Thanks for the reply - the code is a mess right now and in that mess it actually started updating properly. I have to clean it up and if the problem comes back I will post the code.
So I ended up fixing the display update problem by putting my code into a callback function and using on_click in my button arguments. However, now that callback function seems to be getting executed unexpectedly, not just when that button clicks. For example, when I use a toggle a radio button menu on the site it actually executes the on_click callback function for the button.
Are there any past threads about call back functions being unexpectedly run that you know of?
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.