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)
| 1246 | return sorted(self._shapes.keys()) |
| 1247 | |
| 1248 | def onclick(self, fun, btn=1, add=None): |
| 1249 | """Bind fun to mouse-click event on canvas. |
| 1250 | |
| 1251 | Arguments: |
| 1252 | fun -- a function with two arguments, the coordinates of the |
| 1253 | clicked point on the canvas. |
| 1254 | btn -- the number of the mouse-button, defaults to 1 |
| 1255 | |
| 1256 | Example (for a TurtleScreen instance named screen) |
| 1257 | |
| 1258 | >>> screen.onclick(goto) |
| 1259 | >>> # Subsequently clicking into the TurtleScreen will |
| 1260 | >>> # make the turtle move to the clicked point. |
| 1261 | >>> screen.onclick(None) |
| 1262 | """ |
| 1263 | self._onscreenclick(fun, btn, add) |
| 1264 | |
| 1265 | def onkey(self, fun, key): |
| 1266 | """Bind fun to key-release event of key. |