Any plan to support the value of sidebar.slider update?

Any plan to support the value of sidebar.slider update?

Hi @nvidia

This is actually to some extent already possible from Streamlit version 0.84.0 and forward by utilizing callback functions on widgets. See for instance this blogpost for a description and pointers to documentation and my example below setting a slider to random values. There is a bug for range sliders in the current version though.

import streamlit as st
import random

def _update_slider(value):
    st.session_state["test_slider"] = value

if "test_slider" not in st.session_state:
    st.session_state["test_slider"] = 0

st.sidebar.slider("My slider", key="test_slider", min_value=-100, max_value=100)

st.button("Update slider values", on_click=_update_slider, kwargs={"value": random.randint(-100, 100)})

streamlit-small_example-2021-08-12-14-08-80

2 Likes

It’s seems feasible, thank you very much, Peter