drawing with the mouse with turtle

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sat Nov 13 02:05:42 CET 2010

On Fri, 12 Nov 2010 19:24:50 -0500, Brian Blais wrote:

> I'd like to draw on a turtle canvas, but use the mouse to direct the
> turtle.  I don't see a good way of getting the mouse coordinates and the
> button state.

I think the right way to do that is by creating an event handler to the 
turtle. These docs are for Python 2.7 turtle, but they may be applicable 
to older versions as well:


I quote:

    >>> turtle.ondrag(turtle.goto)

    Subsequently, clicking and dragging the Turtle will move it 
    across the screen thereby producing handdrawings (if pen is down).

That's probably all you need to do.


More information about the Python-list mailing list