Two naive Tkinter questions

Pierre Quentel quentel.pierre at wanadoo.fr
Mon Nov 3 16:51:06 EST 2003


--- In python-list at yahoogroups.com, Eric Brunel <eric.brunel at p...> 
wrote:
> Pierre Quentel wrote:
> > When you define self.b1, instead of 
using "command=self.setcolor"  
> > you can bind the event "click with left button" to a callback 
method 
> > by:
> > self.b1=Button(self, bg="red")
> > self.b1.bind("<Button-1>",self.setcolor)
> 
> You shouldn't do that: the usual way buttons work is to run the 
associated 
> command when the mouse button is pressed in it, then released in it 
too. Having 
> the command run when the button is just clicked may seem awkward to 
many users. 
> And emulating the way button usually work with bindings would be 
quite 
> difficult, if not impossible.
> 

There's no need to emulate, with the code above (using "bind") the 
behaviour is the one you describe : the color changes only when the 
button is released (with Python 2.3 on Windows 98 and with Cygwin)







More information about the Python-list mailing list