Bind fun to mouse-click event on canvas. Arguments: fun -- a function with two arguments, the coordinates of the clicked point on the canvas. btn -- the number of the mouse-button, defaults to 1 Example (for a TurtleScreen instance named screen
(self, fun, btn=1, add=None)
| 1348 | return sorted(self._shapes.keys()) |
| 1349 | |
| 1350 | def onclick(self, fun, btn=1, add=None): |
| 1351 | """Bind fun to mouse-click event on canvas. |
| 1352 | |
| 1353 | Arguments: |
| 1354 | fun -- a function with two arguments, the coordinates of the |
| 1355 | clicked point on the canvas. |
| 1356 | btn -- the number of the mouse-button, defaults to 1 |
| 1357 | |
| 1358 | Example (for a TurtleScreen instance named screen) |
| 1359 | |
| 1360 | >>> screen.onclick(goto) |
| 1361 | >>> # Subsequently clicking into the TurtleScreen will |
| 1362 | >>> # make the turtle move to the clicked point. |
| 1363 | >>> screen.onclick(None) |
| 1364 | """ |
| 1365 | self._onscreenclick(fun, btn, add) |
| 1366 | |
| 1367 | def onkey(self, fun, key): |
| 1368 | """Bind fun to key-release event of key. |