MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _onclick

Method _onclick

tools/python-3.11.9-amd64/Lib/turtle.py:604–617  ·  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

602## """may be implemented for some other graphics toolkit"""
603
604 def _onclick(self, item, fun, num=1, add=None):
605 """Bind fun to mouse-click event on turtle.
606 fun must be a function with two arguments, the coordinates
607 of the clicked point on the canvas.
608 num, the number of the mouse-button defaults to 1
609 """
610 if fun is None:
611 self.cv.tag_unbind(item, "<Button-%s>" % num)
612 else:
613 def eventfun(event):
614 x, y = (self.cv.canvasx(event.x)/self.xscale,
615 -self.cv.canvasy(event.y)/self.yscale)
616 fun(x, y)
617 self.cv.tag_bind(item, "<Button-%s>" % num, eventfun, add)
618
619 def _onrelease(self, item, fun, num=1, add=None):
620 """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