Re: How to get a Tk widget's coordinate? How to judge mouse is on a widget or not?




mengrufeng@xxxxxxxxx schrieb:

How to get a Tk widget's coordinate? How to judge mouse is on a widget
or not?

For coordinates, use [winfo geometry $widget] which returns
(width)x(height)+(deltax)+(deltay)
The delta coordinates are relative to its parent window.
For toplevels, [wm geometry $widget] gives the location relative to the
screen in the same format.
When the mouse pointer enters or leaves a widget, <Enter> resp. <Leave>
events are generated. Just bind to them if you want to be notified.
Little example:

pack [button .b -text hello -relief flat]
bind .b <Enter> {.b config -relief raised}
bind .b <Leave> {.b config -relief flat}

.


Quantcast