turtle.ondrag() function in Python Last Updated : 17 Aug, 2020 Comments Improve Suggest changes Like Article Like Report 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. turtle.ondrag() This function is used to bind fun to mouse-move event on this turtle on canvas. Syntax : turtle.ondrag(fun, btn, add) Parameters : 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 : Example : python3 # importing package import turtle # method to call on drag def fxn(x, y): # stop backtracking turtle.ondrag(None) # move the turtle's angle and direction # towards x and y turtle.setheading(turtle.towards(x, y)) # go to x, y turtle.goto(x, y) # call again turtle.ondrag(fxn) # set turtle speed turtle.speed(10) # make turtle screen object sc = turtle.Screen() # set screen size sc.setup(400, 300) # call fxn on drag turtle.ondrag(fxn) # take screen in mainloop sc.mainloop() Output : Comment More infoAdvertise with us Next Article turtle.ondrag() function in Python D deepanshu_rustagi Follow Improve Article Tags : Python Python-turtle Practice Tags : python Similar Reads turtle.onrelease() 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. turtle.onrelease() This function is used to bind fun to the mouse-button-release ev 2 min read turtle.mode() 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. turtle.mode() This function is used to set turtle-mode ('standard', 'logo' or 'worl 1 min read turtle.onkey() 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. turtle.onkey() This function is used to bind fun to the key-release event of the ke 1 min read turtle.ontimer() 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. turtle.ontimer() This function is used to install a timer, which calls fun after t 1 min read turtle.isdown() 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. turtle.isdown() This method is used to check whether the turtle is down or not. It 1 min read turtle.onclick() 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. turtle.onclick() This function is used to bind fun to a mouse-click event on this t 1 min read turtle.heading() 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. turtle.heading() This function is used to return the turtle's current heading. It d 1 min read turtle.onscreenclick() 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. turtle.onscreenclick() This function is used to bind fun to a mouse-click event on 2 min read turtle.dot() 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. turtle.dot()This function is used to draw a circular dot with a particular size, wi 2 min read turtle.get_poly() function in Python he 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. turtle.get_poly() This function is used to return the lastly recorded polygon. It do 1 min read Like