Bind fun to mouse-click event on canvas. fun must be a function with two arguments, the coordinates of the clicked point on the canvas. num, the number of the mouse-button defaults to 1 If a turtle is clicked, first _onclick-event will be performed, then _ons
(self, fun, num=1, add=None)
| 650 | self.cv.tag_bind(item, "<Button%s-Motion>" % num, eventfun, add) |
| 651 | |
| 652 | def _onscreenclick(self, fun, num=1, add=None): |
| 653 | """Bind fun to mouse-click event on canvas. |
| 654 | fun must be a function with two arguments, the coordinates |
| 655 | of the clicked point on the canvas. |
| 656 | num, the number of the mouse-button defaults to 1 |
| 657 | |
| 658 | If a turtle is clicked, first _onclick-event will be performed, |
| 659 | then _onscreensclick-event. |
| 660 | """ |
| 661 | if fun is None: |
| 662 | self.cv.unbind("<Button-%s>" % num) |
| 663 | else: |
| 664 | def eventfun(event): |
| 665 | x, y = (self.cv.canvasx(event.x)/self.xscale, |
| 666 | -self.cv.canvasy(event.y)/self.yscale) |
| 667 | fun(x, y) |
| 668 | self.cv.bind("<Button-%s>" % num, eventfun, add) |
| 669 | |
| 670 | def _onkeyrelease(self, fun, key): |
| 671 | """Bind fun to key-release event of key. |