MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / onclick

Method onclick

tools/python-3.11.9-amd64/Lib/turtle.py:3541–3560  ·  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

3539 return self.screen.delay(delay)
3540
3541 def onclick(self, fun, btn=1, add=None):
3542 """Bind fun to mouse-click event on this turtle on canvas.
3543
3544 Arguments:
3545 fun -- a function with two arguments, to which will be assigned
3546 the coordinates of the clicked point on the canvas.
3547 btn -- number of the mouse-button defaults to 1 (left mouse button).
3548 add -- True or False. If True, new binding will be added, otherwise
3549 it will replace a former binding.
3550
3551 Example for the anonymous turtle, i. e. the procedural way:
3552
3553 >>> def turn(x, y):
3554 ... left(360)
3555 ...
3556 >>> onclick(turn) # Now clicking into the turtle will turn it.
3557 >>> onclick(None) # event-binding will be removed
3558 """
3559 self.screen._onclick(self.turtle._item, fun, btn, add)
3560 self._update()
3561
3562 def onrelease(self, fun, btn=1, add=None):
3563 """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