MCPcopy Index your code
hub / github.com/python/cpython / _onclick

Method _onclick

Lib/turtle.py:597–610  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.

Callers 1

onclickMethod · 0.80

Calls 2

tag_unbindMethod · 0.45
tag_bindMethod · 0.45

Tested by

no test coverage detected