drawing with the mouse with turtle
Brian Blais
bblais at bryant.edu
Fri Nov 12 19:24:50 EST 2010
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 tried to do something like this:
import turtle
def gothere(event):
print event.x
print event.y
turtle.goto(event.x,event.y)
turtle.reset()
turtle.speed(0)
c=turtle.getcanvas()
c.bind("<Button-1>", gothere)
turtle.pendown()
but this seemed to draw in the wrong place (like the coordinates were wrong). Is there a good way to do this?
thanks,
bb
--
Brian Blais
bblais at bryant.edu
http://web.bryant.edu/~bblais
http://bblais.blogspot.com/
More information about the Python-list
mailing list