Slider

Sliders allow users to make selections from a range of values.

https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/slider.png
  • Sliders should present the full range of choices that are available

  • Two types: continuous and discrete

  • The slider should immediately reflect any input made by a user

https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/sliders-types.png
  1. Continuous slider

  2. Discrete slider

Usage

MDSlider(
    MDSliderHandle(
    ),
    MDSliderValueLabel(
    ),
    step=10,
    value=50,
)
MDSlider:
    step: 10
    value: 50

    MDSliderHandle:

    MDSliderValueLabel:

Anatomy

https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/slider-anatomy.png

API - kivymd.uix.slider.slider

class kivymd.uix.slider.slider.MDSlider(*args, **kwargs)

Slider class.

For more information, see in the DeclarativeBehavior and ThemableBehavior and Slider classes documentation.

track_active_width

Width of the active track.

Added in version 2.0.0.

track_active_width is an NumericProperty and defaults to dp(4).

track_inactive_width

Width of the inactive track.

Added in version 2.0.0.

track_inactive_width is an NumericProperty and defaults to dp(4).

step_point_size

Step point size.

Added in version 2.0.0.

step_point_size is an NumericProperty and defaults to dp(1).

track_active_color

Color of the active track.

Added in version 2.0.0.

Changed in version 2.0.0: Rename from track_color_active to track_active_color

track_active_color is an ColorProperty and defaults to None.

track_active_step_point_color

Color of step points on active track.

Added in version 2.0.0.

track_active_step_point_color is an ColorProperty and defaults to None.

track_inactive_step_point_color

Color of step points on inactive track.

Added in version 2.0.0.

track_inactive_step_point_color is an ColorProperty and defaults to None.

track_inactive_color

Color of the inactive track.

Added in version 2.0.0.

Changed in version 2.0.0: Rename from track_color_inactive to track_inactive_color

track_active_color is an ColorProperty and defaults to None.

value_container_show_anim_duration

Duration of the animation opening of the label value.

Added in version 2.0.0.

value_container_show_anim_duration is an NumericProperty and defaults to 0.2.

value_container_hide_anim_duration

Duration of closing the animation of the label value.

Added in version 2.0.0.

value_container_hide_anim_duration is an NumericProperty and defaults to 0.2.

value_container_show_anim_transition

The type of the opening animation of the label value.

Added in version 2.0.0.

value_container_show_anim_transition is an StringProperty and defaults to ‘out_circ’.

value_container_hide_anim_transition

The type of the closing animation of the label value.

Added in version 2.0.0.

value_container_hide_anim_transition is an StringProperty and defaults to ‘out_circ’.

handle_anim_transition

Handle animation type.

Added in version 2.0.0.

handle_anim_transition is an StringProperty and defaults to ‘out_circ’.

handle_anim_duration

Handle animation duration.

Added in version 2.0.0.

handle_anim_duration is an NumericProperty and defaults to 0.2.

add_widget(widget, index=0, canvas=None)

Add a new widget as a child of this widget.

Parameters:
widget: Widget

Widget to add to our list of children.

index: int, defaults to 0

Index to insert the widget in the list. Notice that the default of 0 means the widget is inserted at the beginning of the list and will thus be drawn on top of other sibling widgets. For a full discussion of the index and widget hierarchy, please see the Widgets Programming Guide.

Added in version 1.0.5.

canvas: str, defaults to None

Canvas to add widget’s canvas to. Can be ‘before’, ‘after’ or None for the default canvas.

Added in version 1.9.0.

>>> from kivy.uix.button import Button
>>> from kivy.uix.slider import Slider
>>> root = Widget()
>>> root.add_widget(Button())
>>> slider = Slider()
>>> root.add_widget(slider)
update_points(instance, step) None

Draws the step points on the slider.

on_size(*args) None

Fired when the widget is resized.

on_touch_down(touch)

Receive a touch down event.

Parameters:
touch: MotionEvent class

Touch received. The touch is in parent coordinates. See relativelayout for a discussion on coordinate systems.

Returns:

bool If True, the dispatching of the touch event will stop. If False, the event will continue to be dispatched to the rest of the widget tree.

on_value_pos(*args) None

Fired when the value_pos value changes. Sets a new value for the value label texture.

on_touch_up(touch)

Receive a touch up event. The touch is in parent coordinates.

See on_touch_down() for more information.

on_touch_move(touch)

Receive a touch move event. The touch is in parent coordinates.

See on_touch_down() for more information.

on_handle_enter() None

Scales the container of the label value.

on_handle_leave() None

Scales the container of the label value.

class kivymd.uix.slider.slider.MDSliderHandle(**kwargs)

Handle class.

Added in version 2.0.0.

For more information, see in the ThemableBehavior and BackgroundColorBehavior and FocusBehavior and Widget classes documentation.

radius

Handle radius.

radius is an VariableListProperty and defaults to [dp(10), dp(10), dp(10), dp(10)].

size

Handle size.

size is an ListProperty and defaults to [dp(20), dp(20)].

state_layer_size

Handle state layer size.

state_layer_size is an ListProperty and defaults to [dp(40), dp(40)].

state_layer_color

Handle state layer color.

state_layer_color is an ColorProperty and defaults to None.

on_enter() None

Fired when mouse enter the bbox of the widget. Animates the display of the slider handle layer.

on_leave() None

Fired when the mouse goes outside the widget border. Animates the hiding of the slider handle layer.

class kivymd.uix.slider.slider.MDSliderValueLabel(*args, **kwargs)

Implements the value label.

For more information, see in the MDLabel class documentation.

Added in version 2.0.0.

size

Container size for the label value.

handle_anim_transition is an ListProperty and defaults to [dp(36), dp(36)].