Tooltip#
See also Tooltips display informative text when users hover over, focus on,
or tap an element. To use the In Kv-language: In Python code: Warning Note The behavior of tooltips on desktop and mobile devices is different.
For more detailed information,
click here.
MDTooltip
class, you must create a new class inherited
from the MDTooltip
class:<TooltipMDIconButton@MDIconButton+MDTooltip>
class TooltipMDIconButton(MDIconButton, MDTooltip):
pass
MDTooltip
only works correctly with button and label classes.from kivy.lang import Builder
from kivymd.app import MDApp
KV = '''
<TooltipMDIconButton@MDIconButton+MDTooltip>
MDScreen:
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()
API - kivymd.uix.tooltip.tooltip
#
- class kivymd.uix.tooltip.tooltip.MDTooltip(**kwargs)#
- Events:
on_enter
Called when mouse enters the bbox of the widget AND the widget is visible
on_leave
Called when the mouse exits the widget AND the widget is visible
- tooltip_bg_color#
Tooltip background color in (r, g, b, a) or string format
tooltip_bg_color
is anColorProperty
and defaults to None.
- tooltip_text_color#
Tooltip text color in (r, g, b, a) or string format
tooltip_text_color
is anColorProperty
and defaults to None.
- tooltip_text#
Tooltip text.
tooltip_text
is anStringProperty
and defaults to ‘’.
- tooltip_font_style#
Tooltip font style. Available options are: ‘H1’, ‘H2’, ‘H3’, ‘H4’, ‘H5’, ‘H6’, ‘Subtitle1’, ‘Subtitle2’, ‘Body1’, ‘Body2’, ‘Button’, ‘Caption’, ‘Overline’, ‘Icon’.
tooltip_font_style
is anOptionProperty
and defaults to ‘Caption’.
- tooltip_radius#
Corner radius values.
radius
is anListProperty
and defaults to [dp(7),].
- tooltip_display_delay#
Tooltip dsiplay delay.
tooltip_display_delay
is anBoundedNumericProperty
and defaults to 0, min of 0 & max of 4. This property only works on desktop.
- shift_y#
Y-offset of tooltip text.
shift_y
is anNumericProperty
and defaults to 0.
- shift_right#
Shifting the tooltip text to the right.
New in version 1.0.0.
shift_right
is anNumericProperty
and defaults to 0.
- shift_left#
Shifting the tooltip text to the left.
New in version 1.0.0.
shift_left
is anNumericProperty
and defaults to 0.
- delete_clock(self, widget, touch, *args)#
- adjust_tooltip_position(self, x: float, y: float)#
Returns the coordinates of the tooltip that fit into the borders of the screen.
- animation_tooltip_show(self, interval: Union[int, float])#
Animation of opening tooltip on the screen.
- animation_tooltip_dismiss(self, interval: Union[int, float])#
New in version 1.0.0.
Animation of closing tooltip on the screen.
- remove_tooltip(self, *args)#
Removes the tooltip widget from the screen.
- on_long_touch(self, touch, *args)#
Called when the widget is pressed for a long time.
- on_enter(self, *args)#
See
on_enter
method inHoverBehavior
class.
- on_leave(self)#
See
on_leave
method inHoverBehavior
class.
- on_show(self)#
Default display event handler.
- on_dismiss(self)#
New in version 1.0.0.
Default dismiss event handler.
- class kivymd.uix.tooltip.tooltip.MDTooltipViewClass(**kwargs)#
Box layout class. See module documentation for more information.
- tooltip_bg_color#
See
tooltip_bg_color
.
- tooltip_text_color#
See
tooltip_text_color
.
- tooltip_text#
See
tooltip_text
.
- tooltip_font_style#
See
tooltip_font_style
.
- tooltip_radius#
See
tooltip_radius
.