Tracking validity in tkinter widget

Bob van der Poel bvdpoel at kootenay.com
Fri Oct 18 12:37:12 EDT 2002


Jeff Epler wrote:
> 
> While the button is pressed, Tk captures mouse motion events and sends them
> to the widget (or, in this case, a canvas item) where the button was first
> pressed.

Thanks, Jeff, for the reply. I looked into this a bit more and checked a
few of the sample programs. Guido's paint.py and Matt's rubber* programs
both demonstrate the same problem. I see 2 solutions (well 3):

1. Use <Enter> and <Leave> events to set a flag and then have the
<B1-Motion> callback check the flag. This actually works fine.

2. Maintain the actual coords of the widget and have the <B1-Motion>
compare the event.x, event.y to the coords.

3. Forget it. If someone wants to move the slider after the cursor has
left the arena, let it move.

After fooling around with this for several hours and running a bunch of
demos, I see that most people are using solution 3. 


-- 
Bob van der Poel ** Wynndel, British Columbia, CANADA **
EMAIL: bvdpoel at kootenay.com
WWW:   http://www.kootenay.com/~bvdpoel





More information about the Python-list mailing list