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
rgba
format.tooltip_bg_color
is anListProperty
and defaults to [].
-
tooltip_text_color
¶ Tooltip text color in
rgba
format.tooltip_text_color
is anListProperty
and defaults to [].
-
tooltip_text
¶ Tooltip text.
tooltip_text
is anStringProperty
and defaults to ‘’.
-
duration_long_touch
¶ Time for a long touch until a tooltip appears. Used only on mobile devices.
duration_long_touch
is anNumericProperty
and 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_enter
method inHoverBehavior
class.
-
on_leave
(self)¶ See
on_leave
method inHoverBehavior
class.
-
-
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
.
-