Chip¶
See also
Chips are compact elements that represent an input, attribute, or action.
Usage¶
MDChip:
label: 'Coffee'
color: .4470588235118, .1960787254902, 0, 1
icon: 'coffee'
callback: app.callback_for_menu_items
The user function takes two arguments - the object and the text of the chip:
def callback_for_menu_items(self, instance, value):
print(instance, value)
Use custom icon¶
MDChip:
label: 'Kivy'
icon: 'data/logo/kivy-icon-256.png'
Use without icon¶
MDChip:
label: 'Without icon'
icon: ''
Chips with check¶
MDChip:
label: 'Check with icon'
icon: 'city'
check: True
Choose chip¶
MDChooseChip:
MDChip:
label: 'Earth'
icon: 'earth'
selected_chip_color: .21176470535294, .098039627451, 1, 1
MDChip:
label: 'Face'
icon: 'face'
selected_chip_color: .21176470535294, .098039627451, 1, 1
MDChip:
label: 'Facebook'
icon: 'facebook'
selected_chip_color: .21176470535294, .098039627451, 1, 1
Note
API - kivymd.uix.chip
¶
-
class
kivymd.uix.chip.
MDChip
(**kwargs)¶ Box layout class. See module documentation for more information.
-
label
¶ Chip text.
label
is anStringProperty
and defaults to ‘’.
-
icon
¶ Chip icon.
icon
is anStringProperty
and defaults to ‘checkbox-blank-circle’.
-
color
¶ Chip color in
rgba
format.color
is anListProperty
and defaults to [].
-
check
¶ If True, a checkmark is added to the left when touch to the chip.
check
is anBooleanProperty
and defaults to False.
-
callback
¶ Custom method.
callback
is anObjectProperty
and defaults to None.
-
radius
¶ Corner radius values.
radius
is anNumericProperty
and defaults to ‘12dp’.
-
selected_chip_color
¶ The color of the chip that is currently selected in
rgba
format.selected_chip_color
is anListProperty
and defaults to [].
-
on_icon
(self, instance, value)¶
-
on_touch_down
(self, 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.
-
-
class
kivymd.uix.chip.
MDChooseChip
(**kwargs)¶ Stack layout class. See module documentation for more information.
-
add_widget
(self, 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)
-