Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do you do tooltips (mouseover text) in tcl/TK? (newbie question)

1,465 views
Skip to first unread message

Phil Marden

unread,
Apr 24, 2001, 12:19:48 PM4/24/01
to
Hi,
I'm fairly new to tcl/TK. How does one implement Windows-like "tooltips",
which is the displaying of text on the screen when the mouse is over an
element on the screen? I'm interested in know how this can be done both in
tcl and in C++ in a custom TK widget. I'm working under Linux.

Are there any examples on the web for this? Any links would be appreciated.

Thanks.

Jeff Godfrey

unread,
Apr 24, 2001, 12:46:16 PM4/24/01
to
Phil,

Doing a search on google for "tcl balloon help" found several links - some
of which are:

http://www.multimania.com/droche/tkballoon/
http://www.jessikat.demon.co.uk/blnhlp.html

Also, the "Bwidget" package has a nice built-in balloon help functionality.
Hope that helps.

Jeff

"Phil Marden" <philip....@intel.com> wrote in message
news:9c4974$m...@news.or.intel.com...

Laurent Duperval

unread,
Apr 24, 2001, 2:12:09 PM4/24/01
to
In article <63iF6.2743$Ib.2...@news1.primary.net>, "Jeff Godfrey"
<jgod...@optinest.com> wrote:

> Phil,
>
> Doing a search on google for "tcl balloon help" found several links -
> some of which are:
>
> http://www.multimania.com/droche/tkballoon/
> http://www.jessikat.demon.co.uk/blnhlp.html
>
> Also, the "Bwidget" package has a nice built-in balloon help
> functionality. Hope that helps.
>

You can also find some code on the Tcl Wiki.

L

--

Donal K. Fellows

unread,
Apr 25, 2001, 4:32:15 AM4/25/01
to
Phil Marden wrote:
> How does one implement Windows-like "tooltips",

Some code I wrote earlier this week...

proc balloonIn {w msg} {
if {![winfo exist .balloon]} {
toplevel .balloon
wm overrideredirect .balloon 1
label .balloon.l -foreground blue -background yellow \
-highlightthick 0 -relief solid -borderwidth 1 \
-font {Helvetica -10} -textvariable balloon_text
pack .balloon.l
}
set ::balloon_text $msg
set x [expr {[winfo rootx $w]+10}]
set y [expr {[winfo rooty $w]+[winfo height $w]+5}]
set g [format +%d+%d $x $y]
# This is probably overdoing it, but better too much than too little
wm geometry .balloon $g
wm deiconify .balloon
wm geometry .balloon $g
raise .balloon
after idle "[list wm geometry .balloon $g]; raise .balloon"
}
proc balloonOut {} {
if {[winfo exist .balloon]} {
wm withdraw .balloon
}
}
# Message in $msg, balloon relative to widget $r, bind to
# widgets listed in remaining arguments.
proc bindBalloon {msg r args} {
foreach w $args {
bind $w <Enter> [namespace code [list balloonIn $r $msg]]
bind $w <Leave> [namespace code balloonOut]
}
}

### DEMO CODE ###
pack [button .b1 -text Hi -command {puts "Hello there"}]
pack [button .b2 -text Bye -command {exit}]
bindBalloon "Says a friendly message" . .b1
bindBalloon "Quits the program" . .b2

Having the separate argument for specifying which widget the balloon
is to be relative to is a great help when working with more complex
layouts - particularly pseudo-megawidgets - where you want the same
message to be bound to several different widgets.

Donal.
--
Donal K. Fellows http://www.cs.man.ac.uk/~fellowsd/ fell...@cs.man.ac.uk
-- Always running as a superuser is not a fault, it's an OS preference.
-- <mz...@hotmail.com>

patil....@gmail.com

unread,
Apr 6, 2017, 7:29:46 AM4/6/17
to
Hi Donal,

How can we bind these tooltips(mouseover text) for TCL tree ?

Can you please help me in this regard ?


Regards
Jaydeep Patil

Rich

unread,
Apr 6, 2017, 10:11:50 AM4/6/17
to
patil....@gmail.com wrote:
> How can we bind these tooltips(mouseover text) for TCL tree ?
>
> Can you please help me in this regard ?

Install TkLib. It contains a tooltip module.

Then read the documentation for the TkLib tooltip module.

Luis Alejandro Muzzachiodi

unread,
Apr 6, 2017, 4:10:42 PM4/6/17
to
http://wiki.tcl.tk/3060 (there is a mention of treeview tooltips).

ifind...@gmail.com

unread,
Apr 7, 2017, 4:16:52 PM4/7/17
to
#!/bin/sh
# \
exec fltkwish "$1" + ${1+"$@"}

Button t.t -label Button -command { puts "Hi, its me, Button %l" } \
-tooltip "Press me to get a message!"

Show t

Wm title t "Tooltip demonstration"

fatb...@gmail.com

unread,
Feb 22, 2018, 7:24:10 PM2/22/18
to
On Thursday, 6 April 2017 13:10:42 UTC-7, Luis Alejandro Muzzachiodi wrote:
> http://wiki.tcl.tk/3060 (there is a mention of treeview tooltips).

Any idea on how to get comboboxes with tooltips for the elements?

Rich

unread,
Feb 22, 2018, 9:29:02 PM2/22/18
to
Provided the elements of the combobox is a listbox (this is usually the
case) and you can obtain the widget name of the listbox, then you could
use the TkLib tooltip library to add tool tips.

https://core.tcl.tk/tklib/doc/trunk/embedded/www/tklib/files/modules/tooltip/tooltip.html

Note that the docs do state that you the programmer are responsible for
managing the linkage between listbox elements and tooltip messages.
0 new messages