[Tutor] Button 1 Motion Event

Luke Paireepinart rabidpoobear at gmail.com
Wed Dec 5 02:26:05 CET 2007


Johnston Jiaa wrote:
> I'm creating a drawing program, like MS Paint in Tkinter.  I bound  
> the <B1-Motion> event to my Canvas object.  The function it's bound  
> to creates an oval at the event's x and y attributes.
>
> This works fine if the user is dragging slowly, but if he does a  
> sudden dragging motion, the ovals are very far apart.  Is there any  
> way to fix this?
>
> Johnston Jiaa
>   
Windows (and I assume other GUIs such as X) don't report every single 
location the mouse was, when it's moving quickly.  So you'll have to 
interpolate a line between the two points and draw a series of ovals.  
This can be seen in Paint if you use the pencil tool and then make 
u-shaped motions.  If you do it fast enough, they'll be a series of 
angled lines, rather than one smooth U.  There may be a way to get 
around this, but you might have to go to the driver level (depending on 
where it's leaving off the points.  The mouse itself might only sample 
its location every few milliseconds, and this may be causing the issue, 
in which case you'd have to update your hardware.)
That being said, you should still post your code, because there may be 
something that's causing the mouse events to be delayed for whatever reason.
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>   



More information about the Tutor mailing list