[Tkinter-discuss] Hint text

Michael Lange klappnase at web.de
Thu Dec 29 11:46:30 CET 2011


Hi Charles,

Thus spoketh Charles Hixson <charleshixsn at earthlink.net> 
unto us on Wed, 28 Dec 2011 21:11:20 -0800:

> Is there any way to show hints on mouseovers that doesn't require 
> writing a separate function for each, e.g., Radiobutton?
> 
> The only thing I've seen documentation say changes on mouseovers is the 
> state, and the documentation says it will call the command whenever the 
> state changes...but I don't see any way to tell what is having it's 
> state changed except by having different commands for each selection.
> 

unfortunately there is no such thing built into Tk by default, so you
will have to stick with some extra module. The good news is that there
are plenty of those available ready to use.
If installing the Pmw package is an option for you, you might want to
have a look at the Pmw.Ballon class:

http://pmw.sourceforge.net/doc/Balloon.html

I think Tix has a ballon widget either, but I haven't used Tix for a
couple of years, so I'm not exactly sure ;)

If you have IDLE already installed you can use its ToolTip class, like
this:

>>> from Tkinter import *
>>> from idlelib import ToolTip
>>> b=Button(text='foo')
>>> b.pack()
>>> ToolTip.ToolTip(b, 'bla')

In case you don't want to install IDLE, there is also a modified version
of IDLE's ToolTip available as a stand-alone module at:
http://tkinter.unpy.net/wiki/ToolTip

I hope this helps

Michael


.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

We Klingons believe as you do -- the sick should die.  Only the strong
should live.
		-- Kras, "Friday's Child", stardate 3497.2


More information about the Tkinter-discuss mailing list