Bind fun to mouse-click event on turtle. 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
(self, item, fun, num=1, add=None)
| 595 | return item, x1-1 |
| 596 | |
| 597 | def _onclick(self, item, fun, num=1, add=None): |
| 598 | """Bind fun to mouse-click event on turtle. |
| 599 | fun must be a function with two arguments, the coordinates |
| 600 | of the clicked point on the canvas. |
| 601 | num, the number of the mouse-button defaults to 1 |
| 602 | """ |
| 603 | if fun is None: |
| 604 | self.cv.tag_unbind(item, "<Button-%s>" % num) |
| 605 | else: |
| 606 | def eventfun(event): |
| 607 | x, y = (self.cv.canvasx(event.x)/self.xscale, |
| 608 | -self.cv.canvasy(event.y)/self.yscale) |
| 609 | fun(x, y) |
| 610 | self.cv.tag_bind(item, "<Button-%s>" % num, eventfun, add) |
| 611 | |
| 612 | def _onrelease(self, item, fun, num=1, add=None): |
| 613 | """Bind fun to mouse-button-release event on turtle. |
no test coverage detected