turtle.ondrag() function in Python
The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses tkinter for the underlying graphics, it needs a version of Python installed with Tk support.
This function is used to bind fun to mouse-move event on this turtle on canvas.
Syntax : turtle.ondrag(fun, btn, add)
- fun : a function with two arguments, to which will be assigned the coordinates of the clicked point on the canvas
- btn : number of the mouse-button defaults to 1 (left mouse button)
- add : True or False. If True, new binding will be added, otherwise it will replace a former binding
Below is the implementation of the above method with an example :