Bind fun to mouse-button-release event on turtle. fun must be a function with two arguments, the coordinates of the point on the canvas where mouse button is released. num, the number of the mouse-button defaults to 1 If a turtle is clicked, first _onclick-event will
(self, item, fun, num=1, add=None)
| 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. |
| 614 | fun must be a function with two arguments, the coordinates |
| 615 | of the point on the canvas where mouse button is released. |
| 616 | num, the number of the mouse-button defaults to 1 |
| 617 | |
| 618 | If a turtle is clicked, first _onclick-event will be performed, |
| 619 | then _onscreensclick-event. |
| 620 | """ |
| 621 | if fun is None: |
| 622 | self.cv.tag_unbind(item, "<Button%s-ButtonRelease>" % num) |
| 623 | else: |
| 624 | def eventfun(event): |
| 625 | x, y = (self.cv.canvasx(event.x)/self.xscale, |
| 626 | -self.cv.canvasy(event.y)/self.yscale) |
| 627 | fun(x, y) |
| 628 | self.cv.tag_bind(item, "<Button%s-ButtonRelease>" % num, |
| 629 | eventfun, add) |
| 630 | |
| 631 | def _ondrag(self, item, fun, num=1, add=None): |
| 632 | """Bind fun to mouse-move-event (with pressed mouse button) on turtle. |
no test coverage detected