MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / _onrelease

Method _onrelease

Python/Turtle.py:517–534  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

515 self.cv.tag_bind(item, "<Button-%s>" % num, eventfun, add)
516
517 def _onrelease(self, item, fun, num=1, add=None):
518 """Bind fun to mouse-button-release event on turtle.
519 fun must be a function with two arguments, the coordinates
520 of the point on the canvas where mouse button is released.
521 num, the number of the mouse-button defaults to 1
522
523 If a turtle is clicked, first _onclick-event will be performed,
524 then _onscreensclick-event.
525 """
526 if fun is None:
527 self.cv.tag_unbind(item, "<Button%s-ButtonRelease>" % num)
528 else:
529 def eventfun(event):
530 x, y = (self.cv.canvasx(event.x)/self.xscale,
531 -self.cv.canvasy(event.y)/self.yscale)
532 fun(x, y)
533 self.cv.tag_bind(item, "<Button%s-ButtonRelease>" % num,
534 eventfun, add)
535
536 def _ondrag(self, item, fun, num=1, add=None):
537 """Bind fun to mouse-move-event (with pressed mouse button) on turtle.

Callers 1

onreleaseMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected