gtk.TooltipAdd tips to your widgets (new in PyGTK 2.12)Synopsisgtk.Tooltipgobject.GObjectset_customwidgetset_iconpixbufset_icon_from_icon_nameicon_namesizeset_icon_from_stockstock_idsizeset_icon_from_gicongiconsizeset_markupmarkupset_texttextFunctionsgtk.tooltip_trigger_tooltip_querydisplayAncestry+-- gobject.GObject
+-- gtk.Tooltip
Descriptiongtk.Tooltip
belongs to the new tooltips API that was introduced in GTK+ 2.12 and which
deprecates the old gtk.Tooltips API.
Basic tooltips can be realized simply by using
gtk.Widget.set_tooltip_text() or
gtk.Widget.set_tooltip_markup()
without any explicit tooltip object.
When you need a tooltip with a little more fancy contents, like adding an image,
or you want the tooltip to have different contents per
gtk.TreeView row or cell,
you will have to do a little more work:
Set the GtkWidget:has-tooltip property to True,
this will make GTK+ monitor the widget for motion and related events
which are needed to determine when and where to show a tooltip.
Connect to the GtkWidget::query-tooltip
signal. This signal will be emitted
when a tooltip is supposed to be shown. One of the arguments passed to the
signal handler is a
gtk.Tooltip
object. This is the object that we are about
to display as a tooltip, and can be manipulated in your callback using functions
like set_icon.
There are functions for setting the tooltip's markup,
setting an image from a stock icon, or even putting in a custom widget.
Return True from your query-tooltip handler. This causes the
tooltip to be show. If you return False, it will not be shown.
In the probably rare case where you want to have even more control over the tooltip that
is about to be shown, you can set your own
gtk.Window which will be used as tooltip window.
This works as follows:
Set GtkWidget:has-tooltip and connect to
GtkWidget::query-tooltip
as before.
Use gtk.Widget.set_tooltip_window()
to set a gtk.Window created by you as tooltip window.
In the ::query-tooltip callback you can access your window using
gtk.Widget.get_tooltip_window()
and manipulate as you wish. The semantics of the return value are exactly as before,
return True to show the window, False to not show it.
Methodsgtk.Tooltip.set_customset_customwidgetwidget :A
gtk.WidgetThis method is available in PyGTK 2.12 and above.
The set_custom() method replaces the widget packed into
the tooltip with custom_widget. By default a box with a
gtk.Image and
gtk.Label is
embedded in the tooltip, which can be configured using
set_markup and
set_icon.
gtk.Tooltip.set_iconget_valuepixbufpixbuf :A
gtk.gdk.Pixbuf
or None.This method is available in PyGTK 2.12 and above.
The set_icon() method sets the icon of the tooltip
(which is in front of the text) to be pixbuf.
If pixbuf is None, the image will be hidden.
gtk.Tooltip.set_icon_from_icon_nameset_icon_from_icon_nameicon_namesizeicon_name :an icon name, or None.size :A stock icon size.This method is available in PyGTK 2.14 and above.
The set_icon_from_icon_name() method sets the icon of the tooltip
(which is in front of the text) to be the icon indicated by icon_name
with the size indicated by size. If icon_name is None,
the image will be hidden.
gtk.Tooltip.set_icon_from_stockset_icon_from_stockstock_idsizestock_id :A stock icon name, or None.size :A stock icon size.This method is available in PyGTK 2.12 and above.
The set_icon_from_stock() method sets the icon of the tooltip
(which is in front of the text) to be the stock item indicated by stock_id
with the size indicated by size. If stock_id is None,
the image will be hidden.
gtk.Tooltip.set_icon_from_giconset_icon_from_gicongiconsizegicon :the icon to set, or None..size :a stock icon size.This method is available in PyGTK 2.20 and above.The set_icon_from_gicon() method sets the icon of the
tooltip (which is in front of the text) to be the icon indicated by gicon
with the size indicated by size. If gicon is None,
the image will be hidden.gtk.Tooltip.set_markupset_markupmarkupmarkup :A markup string (see Pango markup format)
or None.This method is available in PyGTK 2.12 and above.
The set_markup() method sets the text of the tooltip to be
markup, which is marked up with the Pango text markup language.
If markup is None, the label will be hidden.
gtk.Tooltip.set_textset_texttexttext :A text string or None.This method is available in PyGTK 2.12 and above.
The set_text() method sets the text of the tooltip to be text.
If text is None, the label will be hidden. See also
set_markup.
Functionsgtk.tooltip_trigger_tooltip_querytooltip_trigger_tooltip_querydisplaydisplay :A
gtk.gdk.DisplayThis function is available in PyGTK 2.12 and above.
The tooltip_trigger_tooltip_query() function triggers a
new tooltip query on display, in order to update the current visible tooltip,
or to show/hide the current tooltip. This function is useful to call when, for example,
the state of the widget changed by a key press.