Table Of Contents
Slider¶
The Slider widget looks like a scrollbar. It supports horizontal and
vertical orientations, min/max values and a default value.
To create a slider from -100 to 100 starting from 25:
from kivy.uix.slider import Slider
s = Slider(min=-100, max=100, value=25)
To create a vertical slider:
from kivy.uix.slider import Slider
s = Slider(orientation='vertical')
-
class
kivy.uix.slider.Slider(**kwargs)[source]¶ Bases:
kivy.uix.widget.WidgetClass for creating a Slider widget.
Check module documentation for more details.
-
max¶ Maximum value allowed for
value.maxis aNumericPropertyand defaults to 100.
-
min¶ Minimum value allowed for
value.minis aNumericPropertyand defaults to 0.
-
orientation¶ Orientation of the slider.
orientationis anOptionPropertyand defaults to ‘horizontal’. Can take a value of ‘vertical’ or ‘horizontal’.
-
padding¶ Padding of the slider. The padding is used for graphical representation and interaction. It prevents the cursor from going out of the bounds of the slider bounding box.
By default, padding is sp(16). The range of the slider is reduced from padding *2 on the screen. It allows drawing the default cursor of sp(32) width without having the cursor go out of the widget.
paddingis aNumericPropertyand defaults to sp(16).
-
range¶ Range of the slider in the format (minimum value, maximum value):
>>> slider = Slider(min=10, max=80) >>> slider.range [10, 80] >>> slider.range = (20, 100) >>> slider.min 20 >>> slider.max 100
rangeis aReferenceListPropertyof (min,max) properties.
-
step¶ Step size of the slider.
New in version 1.4.0.
Determines the size of each interval or step the slider takes between min and max. If the value range can’t be evenly divisible by step the last step will be capped by slider.max
stepis aNumericPropertyand defaults to 1.
-
value¶ Current value used for the slider.
valueis aNumericPropertyand defaults to 0.
-
value_normalized¶ Normalized value inside the
range(min/max) to 0-1 range:>>> slider = Slider(value=50, min=0, max=100) >>> slider.value 50 >>> slider.value_normalized 0.5 >>> slider.value = 0 >>> slider.value_normalized 0 >>> slider.value = 100 >>> slider.value_normalized 1
You can also use it for setting the real value without knowing the minimum and maximum:
>>> slider = Slider(min=0, max=200) >>> slider.value_normalized = .5 >>> slider.value 100 >>> slider.value_normalized = 1. >>> slider.value 200
value_normalizedis anAliasProperty.
-
value_pos¶ Position of the internal cursor, based on the normalized value.
value_posis anAliasProperty.
-