Skip to content

Commit b9de457

Browse files
authored
1 parent 5a1e1d9 commit b9de457

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

examples/core/slider.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
import streamlit as st
1717

18-
w1 = st.slider('Label 1', 25, 0, 100, 1)
18+
w1 = st.slider('Label 1', 0, 100, 25, 1)
1919
st.write('Value 1:', w1)
2020

21-
w2 = st.slider('Label 2', (25.0, 75.0), 0.0, 100.0, 0.5)
21+
w2 = st.slider('Label 2', 0.0, 100.0, (25.0, 75.0), 0.5)
2222
st.write('Value 2:', w2)

lib/streamlit/DeltaGenerator.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,24 +1372,24 @@ def selectbox(self, element, ui_value, label, options, index=0,
13721372
return options[current_value] if len(options) else NoValue
13731373

13741374
@_widget
1375-
def slider(self, element, ui_value, label, value=None,
1376-
min_value=None, max_value=None, step=None):
1375+
def slider(self, element, ui_value, label,
1376+
min_value=None, max_value=None, value=None, step=None):
13771377
"""Display a slider widget.
13781378
13791379
Parameters
13801380
----------
13811381
label : str
13821382
A short label explaining to the user what this slider is for.
1383-
value : int/float or a tuple/list of int/float
1384-
The value of this widget when it first renders. In case the value
1385-
is passed as a tuple/list a range slider will be used.
1386-
Defaults to 0.
13871383
min_value : int/float
13881384
The minimum permitted value.
13891385
Defaults to 0 if the value is an int, 0.0 otherwise.
13901386
max_value : int/float
13911387
The maximum permitted value.
13921388
Defaults 100 if the value is an int, 1.0 otherwise.
1389+
value : int/float or a tuple/list of int/float
1390+
The value of this widget when it first renders. In case the value
1391+
is passed as a tuple/list a range slider will be used.
1392+
Defaults to min_value.
13931393
step : int/float
13941394
The stepping interval.
13951395
Defaults to 1 if the value is an int, 0.01 otherwise.
@@ -1413,7 +1413,7 @@ def slider(self, element, ui_value, label, value=None,
14131413
"""
14141414
# Set value default.
14151415
if value is None:
1416-
value = 0
1416+
value = min_value if min_value is not None else 0
14171417

14181418
# Ensure that the value is either a single value or a range of values.
14191419
single_value = isinstance(value, (int, float))

lib/tests/streamlit/slider_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_just_label(self):
4242
])
4343
def test_value_types(self, arg_value, proto_value, return_value):
4444
"""Test that it supports different types of values."""
45-
ret = st.slider('the label', arg_value)
45+
ret = st.slider('the label', value=arg_value)
4646

4747
self.assertEqual(ret, return_value)
4848

@@ -52,22 +52,22 @@ def test_value_types(self, arg_value, proto_value, return_value):
5252

5353
def test_value_greater_than_min(self):
5454
with pytest.raises(ValueError) as exc_slider:
55-
st.slider('Slider label', 0, 10, 100)
55+
st.slider('Slider label', 10, 100, 0)
5656
assert ('The default `value` of 0 must lie between the `min_value` of '
5757
'10 and the `max_value` of 100, inclusively.'
5858
== str(exc_slider.value))
5959

6060
def test_value_smaller_than_max(self):
6161
with pytest.raises(ValueError) as exc_slider:
62-
st.slider('Slider label', 101, 10, 100)
62+
st.slider('Slider label', 10, 100, 101)
6363
assert ('The default `value` of 101 '
6464
'must lie between the `min_value` of 10 '
6565
'and the `max_value` of 100, inclusively.'
6666
== str(exc_slider.value))
6767

6868
def test_max_min(self):
6969
with pytest.raises(ValueError) as exc_slider:
70-
st.slider('Slider label', 101, 101, 100)
70+
st.slider('Slider label', 101, 100, 101)
7171
assert ('The default `value` of 101 '
7272
'must lie between the `min_value` of 101 '
7373
'and the `max_value` of 100, inclusively.'

0 commit comments

Comments
 (0)