turtle.onscreenclick()

turtle.onscreenclick(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-click events on this screen. If fun is None, existing bindings are removed.

Example for a TurtleScreen instance named screen and a Turtle instance named turtle:

>>> screen.onclick(turtle.goto) # Subsequently clicking into the TurtleScreen will
>>>                             # make the turtle move to the clicked point.
>>> screen.onclick(None)        # remove event binding again

Note

This TurtleScreen method is available as a global function only under the name onscreenclick. The global function onclick is another one derived from the Turtle method onclick.

doc_python
2016-10-07 17:45:34
Comments
Leave a Comment

Please login to continue.