User Animation Card¶
Example¶
from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.factory import Factory
from kivymd.toast import toast
from kivymd.theming import ThemeManager
from kivymd.uix.useranimationcard import MDUserAnimationCard
from kivymd.uix.button import MDIconButton
from kivymd.uix.list import ILeftBodyTouch
# Your content for a contact card.
Builder.load_string('''
#:import get_hex_from_color kivy.utils.get_hex_from_color
<TestAnimationCard@MDBoxLayout>
orientation: 'vertical'
padding: dp(10)
spacing: dp(10)
adaptive_height: True
MDBoxLayout:
adaptive_height: True
Widget:
MDRoundFlatButton:
text: "Free call"
Widget:
MDRoundFlatButton:
text: "Free message"
Widget:
OneLineIconListItem:
text: "Video call"
IconLeftSampleWidget:
icon: 'camera-front-variant'
TwoLineIconListItem:
text: "Call Viber Out"
secondary_text: "[color=%s]Advantageous rates for calls[/color]" % get_hex_from_color(app.theme_cls.primary_color)
IconLeftSampleWidget:
icon: 'phone'
TwoLineIconListItem:
text: "Call over mobile network"
secondary_text: "[color=%s]Operator's tariffs apply[/color]" % get_hex_from_color(app.theme_cls.primary_color)
IconLeftSampleWidget:
icon: 'remote'
''')
class IconLeftSampleWidget(ILeftBodyTouch, MDIconButton):
pass
class Example(MDApp):
title = "Example Animation Card"
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.user_animation_card = None
def build(self):
def main_back_callback():
toast('Close card')
if not self.user_animation_card:
self.user_animation_card = MDUserAnimationCard(
user_name="Lion Lion",
path_to_avatar="./assets/african-lion-951778_1280.jpg",
callback=main_back_callback)
self.user_animation_card.box_content.add_widget(
Factory.TestAnimationCard())
self.user_animation_card.open()
Example().run()
API - kivymd.uix.useranimationcard
¶
-
class
kivymd.uix.useranimationcard.
MDUserAnimationCard
(**kwargs)¶ ModalView class. See module documentation for more information.
- Events
- on_pre_open:
Fired before the ModalView is opened. When this event is fired ModalView is not yet added to window.
- on_open:
Fired when the ModalView is opened.
- on_pre_dismiss:
Fired before the ModalView is closed.
- on_dismiss:
Fired when the ModalView is closed. If the callback returns True, the dismiss will be canceled.
Changed in version 1.11.0: Added events on_pre_open and on_pre_dismiss.
-
user_name
¶
-
path_to_avatar
¶
-
box_content
¶
-
callback
¶
-
on_open
(self)¶
-
on_touch_move
(self, touch)¶ Receive a touch move event. The touch is in parent coordinates.
See
on_touch_down()
for more information.
-
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.
-
on_touch_up
(self, touch)¶ Receive a touch up event. The touch is in parent coordinates.
See
on_touch_down()
for more information.
-
animation_to_bottom
(self)¶
-
animation_to_top
(self)¶
-
class
kivymd.uix.useranimationcard.
UserAnimationCard
(**kwargs)¶ Float layout class. See module documentation for more information.
-
user_name
¶
-
path_to_avatar
¶
-
-
class
kivymd.uix.useranimationcard.
ModifiedToolbar
(**kwargs)¶ Widget class. See module documentation for more information.
- Events
- on_touch_down: (touch, )
Fired when a new touch event occurs. touch is the touch object.
- on_touch_move: (touch, )
Fired when an existing touch moves. touch is the touch object.
- on_touch_up: (touch, )
Fired when an existing touch disappears. touch is the touch object.
- on_kv_post: (base_widget, )
Fired after all the kv rules associated with the widget and all other widgets that are in any of those rules have had all their kv rules applied. base_widget is the base-most widget whose instantiation triggered the kv rules (i.e. the widget instantiated from Python, e.g.
MyWidget()
).Changed in version 1.11.0.
Warning
Adding a __del__ method to a class derived from Widget with Python prior to 3.4 will disable automatic garbage collection for instances of that class. This is because the Widget class creates reference cycles, thereby preventing garbage collection.
Changed in version 1.0.9: Everything related to event properties has been moved to the
EventDispatcher
. Event properties can now be used when contructing a simple class without subclassingWidget
.Changed in version 1.5.0: The constructor now accepts on_* arguments to automatically bind callbacks to properties or events, as in the Kv language.
-
left_action_items
¶
-
title
¶
-
on_left_action_items
(self, instance, value)¶
-
update_action_bar
(self, action_bar, action_bar_items)¶
-
update_action_bar_text_colors
(self, instance, value)¶