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.
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()
from kivy.metrics import dp
from kivymd.app import MDApp
from kivymd.uix.pickers import IOSRulerPicker, IOSRulerPickerLabel
from kivymd.uix.screen import MDScreen
class Example(MDApp):
def build(self):
self.theme_cls.theme_style = "Dark"
return MDScreen(
IOSRulerPicker(
IOSRulerPickerLabel(),
min=100,
max=250,
value=180,
size_hint_y=None,
height=dp(40),
label_step=20,
pos_hint={"center_y": .5},
),
md_bg_color=self.theme_cls.backgroundColor,
)
Example().run()
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
MDLabelclass.- formatter#
Callable function used to format numeric values into custom text strings for labels.
formatteris anObjectPropertyand 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
DeclarativeBehaviorandThemableBehaviorandIOSNativeBehaviorandWidgetclasses documentation.- step#
Value interval between adjacent ticks.
stepis aNumericPropertyand defaults to 1.
- min#
Minimum selectable value on the ruler.
minis aNumericPropertyand defaults to 100.
- max#
Maximum selectable value on the ruler.
maxis aNumericPropertyand defaults to 250.
- value#
Current selected value on the ruler.
valueis aNumericPropertyand defaults to 0.
- division_distance#
Physical distance between adjacent tick marks in density-independent pixels.
division_distanceis aNumericPropertyand defaults to dp(12).
- tick_width#
Width of individual ruler tick lines.
tick_widthis aNumericPropertyand defaults to dp(2).
- center_indicator_width#
Width of the static center indicator marker.
center_indicator_widthis aNumericPropertyand defaults to dp(4).
- indicator_color#
Color of the static center indicator marker in RGBA format.
indicator_coloris aColorPropertyand defaults to None.
- primary_tick_color#
Color of the ruler tick marks in RGBA format.
primary_tick_coloris aColorPropertyand 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_coloris aColorPropertyand defaults to None.
- label#
Optional
IOSRulerPickerLabelinstance used to render numeric labels under tick marks. If None, labels will not be displayed.labelis anObjectPropertyand defaults to None.
- label_step#
Interval step between displayed numeric labels (e.g., 1 for every tick, 5 for major ticks).
label_stepis aNumericPropertyand 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.
- 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_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.