MCPcopy Index your code
hub / github.com/python/cpython / onclick

Method onclick

Lib/turtle.py:3675–3694  ·  view source on GitHub ↗

Bind fun to mouse-click 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. btn -- number of the mouse-button defaults to 1 (left mouse button).

(self, fun, btn=1, add=None)

Source from the content-addressed store, hash-verified

3673 return self.screen.delay(delay)
3674
3675 def onclick(self, fun, btn=1, add=None):
3676 """Bind fun to mouse-click event on this turtle on canvas.
3677
3678 Arguments:
3679 fun -- a function with two arguments, to which will be assigned
3680 the coordinates of the clicked point on the canvas.
3681 btn -- number of the mouse-button defaults to 1 (left mouse button).
3682 add -- True or False. If True, new binding will be added, otherwise
3683 it will replace a former binding.
3684
3685 Example for the anonymous turtle, i. e. the procedural way:
3686
3687 >>> def turn(x, y):
3688 ... left(360)
3689 ...
3690 >>> onclick(turn) # Now clicking into the turtle will turn it.
3691 >>> onclick(None) # event-binding will be removed
3692 """
3693 self.screen._onclick(self.turtle._item, fun, btn, add)
3694 self._update()
3695
3696 def onrelease(self, fun, btn=1, add=None):
3697 """Bind fun to mouse-button-release event on this turtle on canvas.

Callers 3

exitonclickMethod · 0.45
demo2Function · 0.45
__init__Method · 0.45

Calls 2

_updateMethod · 0.95
_onclickMethod · 0.80

Tested by

no test coverage detected