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)
| 3420 | return self.screen.delay(delay) |
| 3421 | |
| 3422 | def onclick(self, fun, btn=1, add=None): |
| 3423 | """Bind fun to mouse-click event on this turtle on canvas. |
| 3424 | |
| 3425 | Arguments: |
| 3426 | fun -- a function with two arguments, to which will be assigned |
| 3427 | the coordinates of the clicked point on the canvas. |
| 3428 | btn -- number of the mouse-button defaults to 1 (left mouse button). |
| 3429 | add -- True or False. If True, new binding will be added, otherwise |
| 3430 | it will replace a former binding. |
| 3431 | |
| 3432 | Example for the anonymous turtle, i. e. the procedural way: |
| 3433 | |
| 3434 | >>> def turn(x, y): |
| 3435 | ... left(360) |
| 3436 | ... |
| 3437 | >>> onclick(turn) # Now clicking into the turtle will turn it. |
| 3438 | >>> onclick(None) # event-binding will be removed |
| 3439 | """ |
| 3440 | self.screen._onclick(self.turtle._item, fun, btn, add) |
| 3441 | self._update() |
| 3442 | |
| 3443 | def onrelease(self, fun, btn=1, add=None): |
| 3444 | """Bind fun to mouse-button-release event on this turtle on canvas. |
no test coverage detected