Two naive Tkinter questions

Pierre Quentel quentel.pierre at wanadoo.fr
Tue Nov 4 08:28:08 EST 2003


--- In python-list at yahoogroups.com, Eric Brunel <eric.brunel at p...> 
wrote:
> Using Python 2.1 with tcl/tk 8.3.2, or Python 2.3 with tcl/tk 
8.4.4 on Linux 
> (Mandrake 8.0), it isn't: press the mouse button in the button, 
hold it, and 
> move the mouse pointer out of the button: you'll see the button 
color has changed...

You're fully right. So far I wasn't the kind of guy who clicks 
inside a button and releases outside, but I'll cure myself. Well, at 
least the color does not change "when the button is just clicked" as 
you first wrote

Just for fun, emulating the correct behaviour can be done by :

self.b1.bind("<ButtonRelease-1>",callback)

and begin callback by testing if the mouse is inside the widget:

if root.winfo_containing(event.x_root,event.y_root) is event.widget:
    (...)

but I admit that using "command" is much easier...







More information about the Python-list mailing list