Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Issue #661: IntSlider value should start at the start keyword value not 0 #689

Merged
merged 2 commits into from
Oct 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions panel/tests/widgets/test_slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ def test_int_slider(document, comm):
slider.value = 0
assert widget.value == 0

# Testing that value matches start value if value not set.
slider_2 = IntSlider(start=1, end=3, name='Slider_2')
widget_2 = slider_2.get_root(document, comm=comm)
assert widget_2.value == widget_2.start


def test_range_slider(document, comm):

Expand Down
5 changes: 5 additions & 0 deletions panel/widgets/slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ class FloatSlider(ContinuousSlider):

class IntSlider(ContinuousSlider):

def __init__(self, **params):
if 'value' not in params:
params['value'] = params.get('start', self.param.start.default)
super(ContinuousSlider, self).__init__(**params)

value = param.Integer(default=0)

start = param.Integer(default=0)
Expand Down