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

Method _ondrag

Lib/turtle.py:631–650  ·  view source on GitHub ↗

Bind fun to mouse-move-event (with pressed mouse button) on turtle. fun must be a function with two arguments, the coordinates of the actual mouse position on the canvas. num, the number of the mouse-button defaults to 1 Every sequence of mouse-move-events on a turtl

(self, item, fun, num=1, add=None)

Source from the content-addressed store, hash-verified

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.
633 fun must be a function with two arguments, the coordinates of the
634 actual mouse position on the canvas.
635 num, the number of the mouse-button defaults to 1
636
637 Every sequence of mouse-move-events on a turtle is preceded by a
638 mouse-click event on that turtle.
639 """
640 if fun is None:
641 self.cv.tag_unbind(item, "<Button%s-Motion>" % num)
642 else:
643 def eventfun(event):
644 try:
645 x, y = (self.cv.canvasx(event.x)/self.xscale,
646 -self.cv.canvasy(event.y)/self.yscale)
647 fun(x, y)
648 except Exception:
649 pass
650 self.cv.tag_bind(item, "<Button%s-Motion>" % num, eventfun, add)
651
652 def _onscreenclick(self, fun, num=1, add=None):
653 """Bind fun to mouse-click event on canvas.

Callers 1

ondragMethod · 0.80

Calls 2

tag_unbindMethod · 0.45
tag_bindMethod · 0.45

Tested by

no test coverage detected