Below is a snipet showing how I create a widget in a sidebar.
(I do so because I need to share the sidebar and its data in a multiple page app)
The animated gif shows what happens when I used it.
You can see the hicups when chosing a new value.
I need to select twice before the new value is effective.
The same hicups occur with any widget that I tested: text, daterange, selectbox, …
Note that the argument value=self.val
is needed when I go for a multipage app where I need to share the selected value with other pages. For a single page app, it can be removed, and the problem disappers.
I don’t understand where this comes from.
And I don’t see how to solve this.
Any idea?
Michel
import streamlit as st
class testClass:
"""A simple test"""
def __init__(self, val=5):
self.val = val
def sidebar(self):
"""Adding widget to the sidebar"""
with st.sidebar:
self.val = st.select_slider(r"$\bold{from}$",
options=[0,1,2,3,4,5,6,7,8,9],
value=self.val)
if not st.session_state:
st.session_state.test = testClass()
st.session_state.test.sidebar()
st.write(st.session_state.test)