Tkinter Text Question

Fredrik Lundh fredrik at pythonware.com
Wed May 25 03:18:11 EDT 2005


James Stroud wrote:

> I would like to get the index of the character closest to the pointer in a
> Text, something like Canvas.find_closest(). I want it to bind to '<Motion>'.
> Does anybody know how this might be done?

use w.index("@x,y" % (event.x, event.y)) to find the character "under" the
pointer, and, if necessary, use w.bbox() and/or w.dlineinfo() on neighbouring
characters/lines to find the "closest" (depending on your definition of closest).

</F> 






More information about the Python-list mailing list