Plasma.ToolTipManager

KDE 4.2 PyKDE API Reference

- KDE's Python API

# ToolTipManager Class Reference

`from PyKDE4.plasma import *`

Inherits: QObject
Namespace: Plasma

## Detailed Description

ToolTipManager plasma/tooltipmanager.h <Plasma/ToolTipManager>

Manages tooltips for QGraphicsWidgets in Plasma

If you want a widget to have a tooltip displayed when the mouse is hovered over it, you should do something like:

     // widget is a QGraphicsWidget*
     Plasma.ToolTipContent data;
     data.mainText = i18n("My Title");
     data.subText = i18n("This is a little tooltip");
     data.image = KIcon("some-icon").pixmap(IconSize(KIconLoader.Desktop));
     Plasma.ToolTipManager.self()->setContent(widget, data);

Note that, since a Plasma.Applet is a QGraphicsWidget, you can use Plasma.ToolTipManager.self()->setContent(this, data); in the applet's init() method to set a tooltip for the whole applet.

The tooltip will be registered automatically by setContent(). It will be automatically unregistered when the associated widget is deleted, freeing the memory used by the tooltip, but you can manually unregister it at any time by calling unregisterWidget().

When a tooltip for a widget is about to be shown, the widget's toolTipAboutToShow slot will be invoked if it exists. Similarly, when a tooltip is hidden, the widget's toolTipHidden() slot will be invoked if it exists. This allows widgets to provide on-demand tooltip data.

## Enumerations
State | { Activated, Inhibited, Deactivated }
## Methods
| __init__ (self, QObject parent=0)
| clearContent (self, QGraphicsWidget widget)
| hide (self, QGraphicsWidget widget)
bool | isVisible (self, QGraphicsWidget widget)
| registerWidget (self, QGraphicsWidget widget)
| setContent (self, QGraphicsWidget widget, Plasma.ToolTipContent data)
| setState (self, Plasma.ToolTipManager.State state)
| show (self, QGraphicsWidget widget)
Plasma.ToolTipManager.State | state (self)
| unregisterWidget (self, QGraphicsWidget widget)
## Static Methods
Plasma.ToolTipManager | self ()

## Method Documentation

__init__ | ( | self, |
|  | QObject | parent=0
| ) |  |  |

Default constructor.

You should normall use self() instead.

clearContent | ( | self, |
|  | QGraphicsWidget | widget
| ) |  |  |

Clears the tooltip data associated with this widget, but keeps the widget registered.

hide | ( | self, |
|  | QGraphicsWidget | widget
| ) |  |  |

Hides the tooltip for a widget immediately.

Parameters:

  | widget | the widget to hide the tooltip for

bool isVisible | ( | self, |
|  | QGraphicsWidget | widget
| ) |  |  |

Find out whether the tooltip for a given widget is currently being displayed.

Parameters:

  | widget | the widget to check the tooltip for

Returns:
  true if the tooltip of the widget is currently displayed, false if not

registerWidget | ( | self, |
|  | QGraphicsWidget | widget
| ) |  |  |

Registers a widget with the tooltip manager.

Note that setContent() will register the widget if it has not already been registered, and so you do not normally need to use the method.

This is useful for creating tooltip content on demand. You can register your widget with registerWidget(), then implement a slot named toolTipAboutToShow for the widget. This will be called before the tooltip is shown, allowing you to set the data with setContent().

If the widget also has a toolTipHidden slot, this will be called after the tooltip is hidden.

Parameters:

  | widget | the desired widget

Plasma.ToolTipManager self | ( |  | ) |

Returns:
  The singleton instance of the manager.

setContent | ( | self, |
|  | QGraphicsWidget | widget,
|  | Plasma.ToolTipContent | data
| ) |  |  |

Sets the content for the tooltip associated with a widget.

Note that this will register the widget with the ToolTipManager if necessary, so there is usually no need to call registerWidget().

Parameters:

  | widget | the widget the tooltip should be associated with
  | data | the content of the tooltip. If an empty Content is passed in, the tooltip content will be reset.

setState | ( | self, |
|  | Plasma.ToolTipManager.State | state
| ) |  |  |

Sets the current state of the manager.

See also:
  State

@arg state the state to put the manager in

show | ( | self, |
|  | QGraphicsWidget | widget
| ) |  |  |

Show the tooltip for a widget registered in the tooltip manager

Parameters:

  | widget | the widget for which the tooltip will be displayed

Plasma.ToolTipManager.State state | ( |  | self ) |

Returns:
  the current state of the manager;
  See also:
    State

unregisterWidget | ( | self, |
|  | QGraphicsWidget | widget
| ) |  |  |

Unregisters a widget from the tooltip manager.

This will free the memory used by the tooltip associated with the widget.

Parameters:

  | widget | the desired widget to delete

## Enumeration Documentation

State

Enumerator:

  Activated = 0 |
  Inhibited |
  Deactivated |