turtle.onrelease()

turtle.onrelease(fun, btn=1, add=None)

Parameters:
  • fun – a function with two arguments which will be called with the coordinates of the clicked point on the canvas
  • num – number of the mouse-button, defaults to 1 (left mouse button)
  • addTrue or False – if True, a new binding will be added, otherwise it will replace a former binding

Bind fun to mouse-button-release events on this turtle. If fun is None, existing bindings are removed.

>>> class MyTurtle(Turtle):
...     def glow(self,x,y):
...         self.fillcolor("red")
...     def unglow(self,x,y):
...         self.fillcolor("")
...
>>> turtle = MyTurtle()
>>> turtle.onclick(turtle.glow)     # clicking on turtle turns fillcolor red,
>>> turtle.onrelease(turtle.unglow) # releasing turns it to transparent.
doc_python
2016-10-07 17:45:34
Comments
Leave a Comment

Please login to continue.