| Purpose: | Embed context sensitive help into a Tcl/Tk application |
| See also: | balloon help |
| Credits: | DKFs answer to a respective question on stack overflow. |
| Pros: | As simple as can be, no external dependencies, no clutter, less distraction |
| Cons: | Always needs space on the GUI, less obvious help for unexperienced users. |
LEG Instead of popping up an extra window for tooltip help:
Example code:
# a global variable, you might want to put this in a namespace
set help "Hover over any widget to get help for it"
proc help {widget text} {
# register help text with widget
bind $widget <Enter> +[list set ::help $text]
bind $widget <Leave> +[list set ::help ""]
}
# create the help text widget somewhere on your applications top level
# window or in some frame $w
label $w.help -textvariable help -anchor nw -justify left
# register help for the help window itself
help $w.help "Hover over any widget to get help for it"% in text gets substituted according to bind rules. Use %% to get a simple percent sign.
Variable substitution in text is done in the moment the help text is registered. See Bindings and variable substitution for hints how to change this.