Tooltip¶
Enhanced tooltips with custom positioning and styling.
Preview
Classes¶
FXTooltip
¶
Bases: ,
A rich, theme-aware tooltip with advanced features.
This widget provides an enhanced tooltip experience with: - Rich content: title, description, icon, images, shortcuts - Smart positioning with arrow pointing to anchor - Theme-aware styling - Fade in/out animations - Hover or programmatic trigger - Configurable delays - Optional action buttons - Persistent mode (stays until clicked away)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
|
Parent widget (anchor for positioning). |
None
|
|
|
Optional title text (bold). |
None
|
|
|
Main tooltip content. |
''
|
|
|
Optional icon name (from fxicons). |
None
|
|
|
Optional QPixmap image to display. |
None
|
|
|
Optional keyboard shortcut to display. |
None
|
|
|
Optional action button text. |
None
|
|
|
Callback for action button click. |
None
|
|
|
Preferred position relative to anchor. |
|
|
|
Delay in ms before showing (default 500). |
500
|
|
|
Delay in ms before hiding after mouse leaves (default 200). |
200
|
|
|
Auto-hide duration in ms (0 = no auto-hide). |
0
|
|
|
If True, tooltip stays until explicitly closed. |
False
|
|
|
Whether to show the pointing arrow. |
True
|
|
|
Maximum width of the tooltip. |
300
|
Signals
shown: Emitted when the tooltip is shown. hidden: Emitted when the tooltip is hidden. action_clicked: Emitted when the action button is clicked.
Examples:
>>> # Simple tooltip attached to a button
>>> tooltip = FXTooltip(
... parent=my_button,
... title="Save",
... description="Save the current file to disk",
... shortcut="Ctrl+S",
... )
>>>
>>> # Rich tooltip with image and action
>>> tooltip = FXTooltip(
... parent=my_widget,
... title="New Feature!",
... description="Click here to learn about the new export options.",
... icon="lightbulb",
... action_text="Learn More",
... action_callback=lambda: show_help(),
... persistent=True,
... )
>>>
>>> # Programmatic show/hide
>>> tooltip.show_tooltip()
>>> tooltip.hide_tooltip()
Methods:
| Name | Description |
|---|---|
|
Handle mouse entering tooltip. |
|
Handle hover events on anchor widget and click-outside detection. |
|
Programmatically hide the tooltip. |
|
Handle mouse leaving tooltip. |
|
Handle click to dismiss persistent tooltip. |
|
Paint the tooltip with arrow. |
|
Change the anchor widget. |
|
Update tooltip content dynamically. |
|
Convenience method to show a tooltip for a widget. |
|
Programmatically show the tooltip. |
eventFilter
¶
Handle hover events on anchor widget and click-outside detection.
set_anchor
¶
Change the anchor widget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
|
New anchor widget. |
required |
set_content
¶
show_for_widget
staticmethod
¶
show_for_widget(
widget : QWidget ,
title : Optional [str ] = None,
description : str = "",
icon : Optional [str ] = None,
shortcut : Optional [str ] = None,
duration : int = 3000,
position : FXTooltipPosition = AUTO ,
) -> FXTooltip
Convenience method to show a tooltip for a widget.
Creates and shows a tooltip immediately, auto-hiding after duration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
|
Widget to show tooltip for. |
required |
|
|
Optional title. |
None
|
|
|
Tooltip description. |
''
|
|
|
Optional icon name. |
None
|
|
|
Optional shortcut text. |
None
|
|
|
Auto-hide duration in ms. |
3000
|
|
|
Tooltip position. |
|
Returns:
| Type | Description |
|---|---|
|
The created FXTooltip instance. |
Examples:
FXTooltipPosition
¶
Bases:
Tooltip position relative to anchor widget.