RulerPicker#

#

Added in version 2.0.1.

A ruler picker displays a scrollable scale of discrete values, allowing people to select a precise number by dragging or flicking through tick marks.

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

Base example#

from kivy.lang import Builder

from kivymd.app import MDApp


KV = '''
MDScreen:
    md_bg_color: self.theme_cls.backgroundColor

    IOSRulerPicker:
        id: ruler
        min: 100
        max: 250
        value: 180
        size_hint_y: None
        height: dp(40)
        label_step: 20
        pos_hint: {"center_y": .5}

        IOSRulerPickerLabel:
            step: 20
'''


class Example(MDApp):
    def build(self):
        return Builder.load_string(KV)



Example().run()
https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/ios-components-ruler-base-example.gif

API - kivymd.uix.pickers.rulerpicker.rulerpicker#

class kivymd.uix.pickers.rulerpicker.rulerpicker.IOSRulerPickerLabel(*args, **kwargs)#

Label configuration widget for IOSRulerPicker.

For more information, see in the MDLabel class.

formatter#

Callable function used to format numeric values into custom text strings for labels.

formatter is an ObjectProperty and defaults to lambda val: str(int(round(val))).

class kivymd.uix.pickers.rulerpicker.rulerpicker.IOSRulerPicker(*args, **kwargs)#

An iOS-style ruler picker widget that allows users to select numeric values by scrolling a visual ruler.

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

step#

Value interval between adjacent ticks.

step is a NumericProperty and defaults to 1.

min#

Minimum selectable value on the ruler.

min is a NumericProperty and defaults to 100.

max#

Maximum selectable value on the ruler.

max is a NumericProperty and defaults to 250.

value#

Current selected value on the ruler.

value is a NumericProperty and defaults to 0.

division_distance#

Physical distance between adjacent tick marks in density-independent pixels.

division_distance is a NumericProperty and defaults to dp(12).

tick_width#

Width of individual ruler tick lines.

tick_width is a NumericProperty and defaults to dp(2).

center_indicator_width#

Width of the static center indicator marker.

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

indicator_color#

Color of the static center indicator marker in RGBA format.

indicator_color is a ColorProperty and defaults to None.

primary_tick_color#

Color of the ruler tick marks in RGBA format.

primary_tick_color is a ColorProperty and defaults to None.

secondary_tick_color#

Color of major tick marks located directly above numeric labels in RGBA format. Accepts a hex string, color name, or RGBA list.

secondary_tick_color is a ColorProperty and defaults to None.

label#

Optional IOSRulerPickerLabel instance used to render numeric labels under tick marks. If None, labels will not be displayed.

label is an ObjectProperty and defaults to None.

label_step#

Interval step between displayed numeric labels (e.g., 1 for every tick, 5 for major ticks).

label_step is a NumericProperty and defaults to 1.

on_value(instance, value)#

Fires native iOS haptic feedback when the discrete step of the ruler is changed.

add_widget(widget, *args, **kwargs)#

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