Allow initialization of range slider with session state #3586
Labels
area:widgets
feature:state
priority:P1
status:confirmed
Bug has been confirmed by the Streamlit team
type:bug
Something isn't working
Summary
I want to be able to create a slider and a checkbox where if the checkbox is unclicked, the slider functions as normal with some default value
val1
, but if the checkbox is clicked, the slider is locked in to a default valueval2
and resets to this value with every rerun, independent of user action.This functionality is possible with a standard slider using session state and key to initialize the slider value depending on the value of the checkbox, however, streamlit throws an error if you attempt to use session state to initialize a tuple of initial values for the slider (i.e. to create a range_slider).
Steps to reproduce
Code snippet:
Functionality for typical single-value slider (this works as expected):
This raises the error:
Expected behavior:
I would like the default slider range to be 30-50 and adjustable if
use_val2
is checked, and 70-90 and fixed ifuse_val2
is not checked.Actual behavior:
Raises
TypeError: (30, 50) has type tuple, but expected one of: int, long, float
Is this a regression?
No
Debug info
The text was updated successfully, but these errors were encountered: