Two naive Tkinter questions
Eric Brunel
eric.brunel at pragmadev.N0SP4M.com
Tue Nov 4 04:11:36 EST 2003
Pierre Quentel wrote:
> --- 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)
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...
--
- Eric Brunel <eric dot brunel at pragmadev dot com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com
More information about the Python-list
mailing list