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)
| 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. |
no test coverage detected