Blocking the selection of the same value in the slider

Is it possible to block the selection of the same option in a two-way slider?

My code:

slider = st.slider(‘Select a time period :’, 1992, 2022, (1992, 2022), 1)

I don’t see any way to do this natively, so you have to manually verify a user’s input and the override it if they tried to select a range of size zero.

I checked GitHub issues and I did not see this as feature request yet. I think this would be a lovely feature request to add: allow setting a “minimum” size (and maybe even a maximum size) for a ranged slider. In a simple case the minimum size might be 1 to simply prevent the start and end from being the same, but more abstractly I could see a usefulness to natively restrict the kind of range that could be selected. Feel free to put in a feature request if it’s something that interests you: Sign in to GitHub · GitHub

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.