Tooltip¶
See also
Tooltips display informative text when users hover over, focus on, or tap an element.
To use the MDTooltip class, you must create a new class inherited
from the MDTooltip class:
In Kv-language:
<TooltipMDIconButton@MDIconButton+MDTooltip>
In Python code:
class TooltipMDIconButton(MDIconButton, MDTooltip):
pass
Warning
MDTooltip only works correctly with button classes.
from kivy.lang import Builder
from kivymd.app import MDApp
KV = '''
<TooltipMDIconButton@MDIconButton+MDTooltip>
Screen:
TooltipMDIconButton:
icon: "language-python"
tooltip_text: self.icon
pos_hint: {"center_x": .5, "center_y": .5}
'''
class Test(MDApp):
def build(self):
return Builder.load_string(KV)
Test().run()
Note
The behavior of tooltips on desktop and mobile devices is different. For more detailed information, click here.
API - kivymd.uix.tooltip¶
-
class
kivymd.uix.tooltip.MDTooltip(**kwargs)¶ Bases:
kivymd.theming.ThemableBehavior,kivymd.uix.behaviors.HoverBehavior,kivy.uix.boxlayout.BoxLayout-
tooltip_bg_color¶ Tooltip background color in
rgbaformat.tooltip_bg_coloris anListPropertyand defaults to [].
-
tooltip_text_color¶ Tooltip text color in
rgbaformat.tooltip_text_coloris anListPropertyand defaults to [].
-
tooltip_text¶ Tooltip text.
tooltip_textis anStringPropertyand defaults to ‘’.
-
duration_long_touch¶ Time for a long touch until a tooltip appears. Used only on mobile devices.
duration_long_touchis anNumericPropertyand defaults to 0.4.
-
create_clock(self, widget, touch, *args)¶
-
delete_clock(self, widget, touch, *args)¶
-
adjust_tooltip_position(self, x, y)¶ Returns the coordinates of the tooltip that fit into the borders of the screen.
-
display_tooltip(self, interval)¶
-
animation_tooltip_show(self, interval)¶
-
remove_tooltip(self, *args)¶
-
on_long_touch(self, touch, *args)¶
-
on_enter(self, *args)¶ See
on_entermethod inHoverBehaviorclass.
-
on_leave(self)¶ See
on_leavemethod inHoverBehaviorclass.
-
-
class
kivymd.uix.tooltip.MDTooltipViewClass¶ Bases:
kivymd.theming.ThemableBehavior,kivy.uix.boxlayout.BoxLayout-
tooltip_bg_color¶ See
tooltip_bg_color.
-
tooltip_text_color¶ See
tooltip_text_color.
-
tooltip_text¶ See
tooltip_text.
-