turtle.Turtle.onrelease¶
-
Turtle.onrelease(fun, btn=1, add=None)¶ Bind fun to mouse-button-release event on this turtle on canvas.
Arguments: fun – a function with two arguments, to which will be assigned
the coordinates of the clicked point on the canvas.num – number of the mouse-button defaults to 1 (left mouse button).
Example (for a MyTurtle instance named joe): >>> class MyTurtle(Turtle): ... def glow(self,x,y): ... self.fillcolor(“red”) ... def unglow(self,x,y): ... self.fillcolor(“”) ... >>> joe = MyTurtle() >>> joe.onclick(joe.glow) >>> joe.onrelease(joe.unglow)
Clicking on joe turns fillcolor red, unclicking turns it to transparent.