turtle.ontimer() function in Python Last Updated : 26 Jul, 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.ontimer() This function is used to install a timer, which calls fun after t milliseconds. Syntax : turtle.ontimer(fun, t=0) Parameters: Arguments Descriptionfuna function with no argumentsta number >= 0 Below is the implementation of the above method with an example : Python3 # import packages import turtle import random # global colors col = ['red', 'yellow', 'green', 'blue', 'white', 'black', 'orange', 'pink'] # method to call on timer def fxn(): global col ind = random.randint(0, 7) # set background color of the # turtle screen randomly sc.bgcolor(col[ind]) # set screen sc = turtle.Screen() sc.setup(400, 300) # loop for timer for i in range(10): turtle.ontimer(fxn, t=400*(i+1)) Output : Here we can find that after some time (set by timer) it automatically changes the background color of the turtle graphics window randomly. Comment More infoAdvertise with us Next Article turtle.ontimer() function in Python D deepanshu_rustagi Follow Improve Article Tags : Python Python-turtle Practice Tags : python Similar Reads 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.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. turtle.ondrag() This function is used to bind fun to mouse-move event on this turtl 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.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.home() 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.home() This function is used to move the turtle to the origin i.e. coordinat 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.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.getpen() 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.getpen() This function is used to return the Turtleobject itself. It doesn't 1 min read turtle.tilt() 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.tilt() This function is used to rotate the turtleshape by the angle from its 1 min read turtle.xcor() 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.xcor() This function is used to return the turtle's x coordinate of the curr 1 min read Like