Learn R Programming

tcltk2 (version 1.2-11)

tk2tip: Display and manage tooltips in Tk widgets

Description

tk2tip provides a simple mechanism to display tooltips on Tk widgets when the mouses hoover on top of them.

Usage

tk2tip(widget, message) tk2killtip() tip(x, ...) "tip"(x, ...) tip(x) <- value "tip"(x) <- value

Arguments

widget
the widget to which a tooltip is attached.
message
the message of the tooltip ("" to remove the tooltip).
x
a tk2widget object.
...
further arguments to the method (unused, but reserved for future use).
value
the message of the tooltip, or "" to remove the tip.

See Also

tk2widgets, tk2methods

Examples

Run this code
## Not run: 
# ## These cannot be run by examples() but should be OK when pasted
# ## into an interactive R session with the tcltk package loaded
# 
# ## Using plain Tcl/Tk label and button (tk2XXX equivalent have built-in
# ## tooltip features)
# tt <- tktoplevel()
# lb <- tklabel(tt, text = "Move mouse over me, or over the button to see tooltip")
# tkgrid(lb)
# tk2tip(lb, "A tooltip for the label \ndisplayed on two lines")
# but <- tkbutton(tt, text = "Exit", width = 10,
#     command = function() tkdestroy(tt2))
# tkgrid(but)
# tk2tip(but, "Exit from this dialog box")
#     
# ## To test tk2killtip(), move mouse on top of a widget
# ## so that the tip is visible, and force killing it manually using:
# tk2killtip()
# ## Move again to the widget: the tip is displayed again.
# 
# ## With tk2widgets, the tip() method can also be used:
# lb2 <- tk2label(tt, text = "Move also over me to see the tooltip")
# tkgrid(lb2)
# tip(lb2) # No tip yet
# tip(lb2) <- "Now the tooltip is there!"
# ## Move the mouse over that last label
# 
# tip(lb2) # Yes, this is my tooltip
# tip(lb2) <- NULL # To eliminate the toltip for this widget
# ## End(Not run)

Run the code above in your browser using DataLab