tooltip(3tk)
π tooltip β Tooltip management π
okay bestie, welcome to tooltip(3tk), the manual page for the Tcl tooltip package π«Ά this is the one that makes lil text messages pop up when your mouse hovers over stuff. iconic behaviour honestly.
β¨ NAME β¨
tooltip β Tooltip management π
πΈ SYNOPSIS πΈ
package require Tcl 8.5
package require tooltip ?2.0.1?
::tooltip::tooltip command ?options?
::tooltip::tooltip pathName ?option value...? ?--? message
π¦ DESCRIPTION π¦
so this package gives you tooltips, which are literally just tiny text messages that show up when the mouse hovers over a widget, a menu item, a canvas item, a listbox item, a ttk::treeview item or column heading, a ttk::notebook tab, or a text widget tag. that's the whole vibe. hover β message β slay β¨
π COMMANDS π
::tooltip::tooltip command ?options?
manage the tooltip package with these subcommands, bestie. here's the whole roster:
clear ?pattern?β stops the specified widgets from showing tooltips.patternis a glob pattern and defaults to matching all widgets. so yeah, no pattern = everybody loses their tooltip, sorry not sorry πconfigure ?option ?value option value ...??β queries or modifies the configuration options of the tooltip. the supported options are-backgroud,-foregroundand-font. (yes it says-backgroud, that's not a typo i made, that's just what it is, no cap π). if no option is specified, it returns a dictionary of the option values. if one option is specified with no value, it returns the value of that option. otherwise, it sets the given options to the corresponding values. β¨delay ?millisecs?β query or set the hover delay. this is the interval that the pointer must remain over the widget before the tooltip is displayed. the delay is specified in milliseconds and must be greater than or equal to 50 ms. with no argument the current delay is returned. πfade ?boolean?β enable or disable fading of the tooltip. the fading is enabled by default on Win32 and Aqua. the tooltip will fade away on Leave events instead disappearing. cute lil exit, honestly πdisable,offβ Disable all tooltips πenable,onβ Enables tooltips for defined widgets. π₯
::tooltip::tooltip pathName ?option value...? ?--? message
this command arranges for widget pathName to display a tooltip with a message. main character energy fr fr π
if the specified widget is a menu, canvas, listbox, ttk::treeview, ttk::notebook or text widget then additional options are used to tie the tooltip to specific menu, canvas or listbox items, ttk::treeview items or column headings, ttk::notebook tabs, or text widget tags.
-headingcolumnId β this option is used to set a tooltip for attk::treeviewcolumn heading. the column does not need to already exist. you should not use the same identifiers for columns and items in a widget for which you are using tooltips as their tooltips will be mixed π. the widget must be attk::treeviewwidget.-imageimage β the specified (photo) image will be displayed to the left of the primary tooltip message. lil glow-up for your tooltip πΌοΈβ¨-indexindex β this option is used to set a tooltip on a menu item. the index may be either the entry index or the entry label. the widget must be a menu widget but the entries do not have to exist when the tooltip is set. future-proof, we love to see it π-infoinfo β the specified info text will be displayed as additional information below the primary tooltip message.-itemsitems β this option is used to set a tooltip for canvas, listbox orttk::treviewitems. for the canvas widget, the item must already be present in the canvas and will be found with afind withtaglookup. for listbox andttk::treviewwidgets the item(s) may be created later but the programmer is responsible for managing the link between the listbox orttk::treviewitem index and the corresponding tooltip. if the listbox orttk::treviewitems are re-ordered, the tooltips will need amending. β οΈ
if the widget is not a canvas, listbox or ttk::treview then an error is raised. π
-tabtabId β the-taboption can be used to set a tooltip for attk::notebooktab. the tab should already be present when this command is called, or an error will be returned. the widget must be attk::notebookwidget.-tagname β the-tagoption can be used to set a tooltip for a text widget tag. the tag should already be present when this command is called, or an error will be returned. the widget must be a text widget.--β the--option marks the end of options. the argument following this one will be treated asmessageeven if it starts with a-. thank u--, our saviour π
π EXAMPLE π
okay this is the part where it gets good. every single one of these is copy-pasteable and correct, keep them exactly as written bestie:
# Demonstrate widget tooltip
package require tooltip
pack [label .l -text "label"]
tooltip::tooltip .l "This is a label widget"
# Demonstrate menu tooltip
package require tooltip
. configure -menu [menu .menu]
.menu add cascade -label Test -menu [menu .menu.test -tearoff 0]
.menu.test add command -label Tooltip
tooltip::tooltip .menu.test -index 0 "This is a menu tooltip"
# Demonstrate canvas item tooltip
package require tooltip
pack [canvas .c]
set item [.c create rectangle 10 10 80 80 -fill red]
tooltip::tooltip .c -item $item "Canvas item tooltip"
# Demonstrate listbox item tooltip
package require tooltip
pack [listbox .lb]
.lb insert 0 "item one"
tooltip::tooltip .lb -item 0 "Listbox item tooltip"
# Demonstrate ttk::notebook tab tooltip
package require tooltip
pack [ttk::notebook .nb]
.nb add [frame .nb.f1 -height 50] -text "First tab"
.nb add [frame .nb.f2 -height 50] -text "Second tab"
tooltip::tooltip .nb -tab 0 "Tooltip for the 1st notebook tab"
tooltip::tooltip .nb -tab 1 "Tooltip for the 2nd notebook tab"
# Demonstrate text tag tooltip
package require tooltip
pack [text .txt]
.txt tag configure TIP-1 -underline 1
tooltip::tooltip .txt -tag TIP-1 "tooltip one text"
.txt insert end "An example of a " {} "tooltip" TIP-1 " tag.\n" {}
π§ MIGRATION FROM VERSION 1 π§
okay so this is the lore drop π. version 1.3 to 1.7 called msgcat::mc before a tooltip was shown, using the tooltip namespace. msgcat::mc requires the caller environment. due to that, version 1.8 recorded the caller namespace and used this in the call. in version 2.0, any msgcat::mc support was removed. the options -namespace, -msgargs and -infoargs were removed. starting with TCL 8.7, msgcat::mc supports oo classes and oo methods. but the oo caller environment is not present when the msgcat::mc was invoked on tooltip display, resulting in runtime errors. it was concluded as bad design to call msgcat::mc late. the caller should reinstall the tooltips on eventual message change. periodt. π
π BUGS, IDEAS, FEEDBACK π
this document, and the package it describes, will undoubtedly contain bugs and other problems (ngl, every doc does π). please report such in the category tooltip of the Tklib Trackers [http://core.tcl.tk/tklib/reportlist](http://core.tcl.tk/tklib/reportlist). please also report any ideas for enhancements you may have for either package and/or documentation. we want the feedback, fr fr π«Ά
β KEYWORDS β
balloon, help, hover, tooltip
π COPYRIGHT π
Copyright (c) 1996-2008, Jeffrey Hobbs
Copyright (c) 2024 Emmanuel Frecon
and that's the whole page bestie, you ate it π this was tooltip(3tk) from tklib, version 2.0.1 β go forth and hover responsibly, ily, bye πβ¨ππ¦
π¦ where this page comes from
- debian trixie: tklib 0.9-1
- ubuntu questing: tklib 0.9-1
- ubuntu resolute: tklib 0.9-1build1
- ubuntu stonking: tklib 0.9-1build1
- Copyright (c) 1996-2008, Jeffrey Hobbs
- Copyright (c) 2024 Emmanuel Frecon
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms