Slider#
#
See also
Sliders allow users to make selections from a range of values.
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
Continuous slider
Discrete slider
Usage#
MDSlider(
MDSliderHandle(
),
MDSliderValueLabel(
),
step=10,
value=50,
)
MDSlider:
step: 10
value: 50
MDSliderHandle:
MDSliderValueLabel:
Anatomy#
API - kivymd.uix.slider.slider
#
- class kivymd.uix.slider.slider.MDSlider(*args, **kwargs)#
Slider class.
For more information, see in the
DeclarativeBehavior
andThemableBehavior
andSlider
classes documentation.- track_active_width#
Width of the active track.
New in version 2.0.0.
track_active_width
is anNumericProperty
and defaults to dp(4).
- track_inactive_width#
Width of the inactive track.
New in version 2.0.0.
track_inactive_width
is anNumericProperty
and defaults to dp(4).
- step_point_size#
Step point size.
New in version 2.0.0.
step_point_size
is anNumericProperty
and defaults to dp(1).
- track_active_color#
Color of the active track.
New in version 2.0.0.
Changed in version 2.0.0: Rename from track_color_active to track_active_color
track_active_color
is anColorProperty
and defaults to None.
- track_active_step_point_color#
Color of step points on active track.
New in version 2.0.0.
track_active_step_point_color
is anColorProperty
and defaults to None.
- track_inactive_step_point_color#
Color of step points on inactive track.
New in version 2.0.0.
track_inactive_step_point_color
is anColorProperty
and defaults to None.
- track_inactive_color#
Color of the inactive track.
New in version 2.0.0.
Changed in version 2.0.0: Rename from track_color_inactive to track_inactive_color
track_active_color
is anColorProperty
and defaults to None.
- value_container_show_anim_duration#
Duration of the animation opening of the label value.
New in version 2.0.0.
value_container_show_anim_duration
is anNumericProperty
and defaults to 0.2.
- value_container_hide_anim_duration#
Duration of closing the animation of the label value.
New in version 2.0.0.
value_container_hide_anim_duration
is anNumericProperty
and defaults to 0.2.
- value_container_show_anim_transition#
The type of the opening animation of the label value.
New in version 2.0.0.
value_container_show_anim_transition
is anStringProperty
and defaults to ‘out_circ’.
- value_container_hide_anim_transition#
The type of the closing animation of the label value.
New in version 2.0.0.
value_container_hide_anim_transition
is anStringProperty
and defaults to ‘out_circ’.
- handle_anim_transition#
Handle animation type.
New in version 2.0.0.
handle_anim_transition
is anStringProperty
and defaults to ‘out_circ’.
- handle_anim_duration#
Handle animation duration.
New in version 2.0.0.
handle_anim_duration
is anNumericProperty
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.
New 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.
New in version 1.9.0.
- widget:
>>> from kivy.uix.button import Button >>> from kivy.uix.slider import Slider >>> root = Widget() >>> root.add_widget(Button()) >>> slider = Slider() >>> root.add_widget(slider)
- 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.
- touch:
- 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.
- class kivymd.uix.slider.slider.MDSliderHandle(**kwargs)#
Handle class.
New in version 2.0.0.
For more information, see in the
ThemableBehavior
andBackgroundColorBehavior
andFocusBehavior
andWidget
classes documentation.- radius#
Handle radius.
radius
is anVariableListProperty
and defaults to [dp(10), dp(10), dp(10), dp(10)].
- size#
Handle size.
size
is anListProperty
and defaults to [dp(20), dp(20)].
- state_layer_size#
Handle state layer size.
state_layer_size
is anListProperty
and defaults to [dp(40), dp(40)].
- state_layer_color#
Handle state layer color.
state_layer_color
is anColorProperty
and defaults to None.
- class kivymd.uix.slider.slider.MDSliderValueLabel(*args, **kwargs)#
Implements the value label.
For more information, see in the
MDLabel
class documentation.New in version 2.0.0.
- size#
Container size for the label value.
handle_anim_transition
is anListProperty
and defaults to [dp(36), dp(36)].