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#
IOS Slider#
See also
A slider is a horizontal track with a control, called a thumb, that people can adjust between a minimum and maximum value.
IOS Usage#
bg_image = FitImage(source="bg.png")
MDScreen(
bg_image,
IOSSlider(
min=0,
max=100,
value=45,
target_background=bg_image,
),
)
MDScreen:
FitImage:
id: bg_image
source: "bg.png"
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
DeclarativeBehaviorandThemableBehaviorandSliderclasses documentation.- track_active_width#
Width of the active track.
Added in version 2.0.0.
track_active_widthis anNumericPropertyand defaults to dp(4).
- track_inactive_width#
Width of the inactive track.
Added in version 2.0.0.
track_inactive_widthis anNumericPropertyand defaults to dp(4).
- step_point_size#
Step point size.
Added in version 2.0.0.
step_point_sizeis anNumericPropertyand 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_coloris anColorPropertyand 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_coloris anColorPropertyand 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_coloris anColorPropertyand 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_coloris anColorPropertyand 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_durationis anNumericPropertyand 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_durationis anNumericPropertyand 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_transitionis anStringPropertyand 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_transitionis anStringPropertyand defaults to ‘out_circ’.
- handle_anim_transition#
Handle animation type.
Added in version 2.0.0.
handle_anim_transitionis anStringPropertyand defaults to ‘out_circ’.
- handle_anim_duration#
Handle animation duration.
Added in version 2.0.0.
handle_anim_durationis anNumericPropertyand 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.
- 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:
MotionEventclass Touch received. The touch is in parent coordinates. See
relativelayoutfor 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.
Added in version 2.0.0.
For more information, see in the
ThemableBehaviorandBackgroundColorBehaviorandStateFocusBehaviorandWidgetclasses documentation.- radius#
Handle radius.
radiusis anVariableListPropertyand defaults to [dp(10), dp(10), dp(10), dp(10)].
- size#
Handle size.
sizeis anListPropertyand defaults to [dp(20), dp(20)].
- state_layer_size#
Handle state layer size.
state_layer_sizeis anListPropertyand defaults to [dp(40), dp(40)].
- state_layer_color#
Handle state layer color.
state_layer_coloris anColorPropertyand defaults to None.
- class kivymd.uix.slider.slider.MDSliderValueLabel(*args, **kwargs)#
Implements the value label.
For more information, see in the
MDLabelclass documentation.Added in version 2.0.0.
- size#
Container size for the label value.
handle_anim_transitionis anListPropertyand 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
DeclarativeBehaviorandThemableBehaviorandFloatLayoutclasses documentation.- min#
Minimum value of the slider.
minis aNumericPropertyand defaults to 0.0.
- max#
Maximum value of the slider.
maxis aNumericPropertyand defaults to 100.0.
- value#
Current value of the slider.
valueis aNumericPropertyand defaults to 0.0.
- step#
Step size for value increments. If 0, value changes continuously.
stepis aNumericPropertyand defaults to 0.0.
- orientation#
Slider orientation. Available options are: ‘horizontal’, ‘vertical’.
orientationis anOptionPropertyand defaults to ‘horizontal’.
- disabled#
Disables touch interaction with the slider when set to True.
disabledis aBooleanPropertyand defaults to False.
- disable_animation#
Disables thumb expansion animations on press.
disable_animationis aBooleanPropertyand defaults to False.
- target_background#
Target widget captured for background sampling and glass effect rendering.
target_backgroundis anObjectPropertyand defaults to None.
- track_height#
Thickness of the slider track line.
track_heightis aNumericPropertyand defaults to dp(6).
- padding#
Padding along the slider track edges to keep the thumb within bounds.
paddingis aNumericPropertyand defaults to dp(16).
- thumb_width#
Default width of the thumb in idle state.
thumb_widthis aNumericPropertyand defaults to dp(28).
- thumb_height#
Default height of the thumb in idle state.
thumb_heightis aNumericPropertyand defaults to dp(28).
- pressed_expansion_width#
Delta increase in thumb width when pressed.
pressed_expansion_widthis aNumericPropertyand defaults to dp(10).
- pressed_expansion_height#
Delta increase in thumb height when pressed.
pressed_expansion_heightis aNumericPropertyand defaults to dp(4).
- track_active_color#
Color of the active (filled) section of the track.
track_active_coloris aColorPropertyand defaults to None.
- track_inactive_color#
Color of the inactive (unfilled) section of the track.
track_inactive_coloris aColorPropertyand defaults to None.
- thumb_color#
Base color tint of the thumb.
thumb_coloris aColorPropertyand defaults to None.
- thumb_color_disabled#
Color tint of the thumb when disabled (disabled=True).
thumb_color_disabledis aColorPropertyand defaults to None.
- value_normalized#
Normalized slider value in range 0.0 to 1.0.
value_normalizedis aNumericPropertyand defaults to 0.0.
- value_pos#
Absolute coordinates (x, y) of the thumb center in canvas space.
value_posis anObjectPropertyand defaults to (0, 0).
- lens_power#
Thumb magnification power at the center of the lens.
lens_poweris anNumericPropertyand defaults to 0.08.
- bevel_power#
Thumb light refraction power at the bevel/edges.
bevel_poweris anNumericPropertyand defaults to 0.15.
- glass_color#
Thumb tint color of the glass in (r, g, b, a) format.
glass_coloris anColorPropertyand defaults to [1.0, 1.0, 1.0, 0.15].
- blur_amount#
Thumb amount of background blur applied inside the glass widget.
blur_amountis anNumericPropertyand defaults to 14.0.
- on_touch_down(touch)#
Receive a touch down event.
- Parameters:
- touch:
MotionEventclass Touch received. The touch is in parent coordinates. See
relativelayoutfor 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_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.