Slider

Contents

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,
)

Anatomy#

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

IOS Slider#

A slider is a horizontal track with a control, called a thumb, that people can adjust between a minimum and maximum value.

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

IOS Usage#

bg_image = FitImage(source="bg.png")
MDScreen(
    bg_image,
    IOSSlider(
        min=0,
        max=100,
        value=45,
        target_background=bg_image,
    ),
)

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 StateFocusBehavior 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)].

class kivymd.uix.slider.slider.IOSSlider(**kwargs)#

iOS-style Liquid Glass Slider with animated thumb expansion on touch interaction.

Added in version 2.0.1.

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

min#

Minimum value of the slider.

min is a NumericProperty and defaults to 0.0.

max#

Maximum value of the slider.

max is a NumericProperty and defaults to 100.0.

value#

Current value of the slider.

value is a NumericProperty and defaults to 0.0.

step#

Step size for value increments. If 0, value changes continuously.

step is a NumericProperty and defaults to 0.0.

orientation#

Slider orientation. Available options are: ‘horizontal’, ‘vertical’.

orientation is an OptionProperty and defaults to ‘horizontal’.

disabled#

Disables touch interaction with the slider when set to True.

disabled is a BooleanProperty and defaults to False.

disable_animation#

Disables thumb expansion animations on press.

disable_animation is a BooleanProperty and defaults to False.

target_background#

Target widget captured for background sampling and glass effect rendering.

target_background is an ObjectProperty and defaults to None.

track_height#

Thickness of the slider track line.

track_height is a NumericProperty and defaults to dp(6).

padding#

Padding along the slider track edges to keep the thumb within bounds.

padding is a NumericProperty and defaults to dp(16).

thumb_width#

Default width of the thumb in idle state.

thumb_width is a NumericProperty and defaults to dp(28).

thumb_height#

Default height of the thumb in idle state.

thumb_height is a NumericProperty and defaults to dp(28).

pressed_expansion_width#

Delta increase in thumb width when pressed.

pressed_expansion_width is a NumericProperty and defaults to dp(10).

pressed_expansion_height#

Delta increase in thumb height when pressed.

pressed_expansion_height is a NumericProperty and defaults to dp(4).

track_active_color#

Color of the active (filled) section of the track.

track_active_color is a ColorProperty and defaults to None.

track_inactive_color#

Color of the inactive (unfilled) section of the track.

track_inactive_color is a ColorProperty and defaults to None.

thumb_color#

Base color tint of the thumb.

thumb_color is a ColorProperty and defaults to None.

thumb_color_disabled#

Color tint of the thumb when disabled (disabled=True).

thumb_color_disabled is a ColorProperty and defaults to None.

value_normalized#

Normalized slider value in range 0.0 to 1.0.

value_normalized is a NumericProperty and defaults to 0.0.

value_pos#

Absolute coordinates (x, y) of the thumb center in canvas space.

value_pos is an ObjectProperty and defaults to (0, 0).

lens_power#

Thumb magnification power at the center of the lens.

lens_power is an NumericProperty and defaults to 0.08.

bevel_power#

Thumb light refraction power at the bevel/edges.

bevel_power is an NumericProperty and defaults to 0.15.

glass_color#

Thumb tint color of the glass in (r, g, b, a) format.

glass_color is an ColorProperty and defaults to [1.0, 1.0, 1.0, 0.15].

blur_amount#

Thumb amount of background blur applied inside the glass widget.

blur_amount is an NumericProperty and defaults to 14.0.

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_touch_move(touch)#

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

See on_touch_down() for more information.

on_touch_up(touch)#

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

See on_touch_down() for more information.