Tethys Platform
Table Of Contents
Table Of Contents

Range Slider

Last Updated: August 10, 2015

class tethys_sdk.gizmos.RangeSlider(name, min, max, initial, step, disabled=False, display_text='', error='', success='', attributes=None, classes='')

Sliders can be used to request an input value from a range of possible values. A slider is configured with a dictionary of key-value options. The table below summarizes the options for sliders.

display_text

Display text for the label that accompanies slider

Type

str

name

Name of the input element that will be used on form submission

Type

str, required

min

Minimum value of range

Type

int, required

max

Maximum value of range

Type

int, required

initial

Initial value of slider

Type

int, required

step

Increment between values in range

Type

int, required

disabled

Disabled state of the slider

Type

bool

error

Error message for form validation

Type

str

success

Success message for form validation

Type

str

attributes

A dictionary representing additional HTML attributes to add to the primary element (e.g. {"onclick": "run_me();"}).

Type

dict

classes

Additional classes to add to the primary HTML element (e.g. "example-class another-class").

Type

str

Example

from tethys_sdk.gizmos import RangeSlider

slider1 = RangeSlider(display_text='Slider 1',
                      name='slider1',
                      min=0,
                      max=100,
                      initial=50,
                      step=1)

slider2 = RangeSlider(display_text='Slider 2',
                      name='slider2',
                      min=0,
                      max=1,
                      initial=0.5,
                      step=0.1,
                      disabled=True,
                      error='Incorrect, please choose another value.')

context = {
            'slider1': slider1,
            'slider2': slider2,
          }

Template Example

{% gizmo slider1 %}
{% gizmo slider2 %}