turtle.setundobuffer() function in Python
Last Updated :
17 May, 2021
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.setundobuffer()
This function is used to set or disable undobuffer. It takes the size parameter. If the size is an integer an empty undobuffer of a given size is installed. Size gives the maximum number of turtle-actions that can be undone by the undo() function. If the size is None, no undobuffer is present.
Syntax :
turtle.setundobuffer(size)
Below is the implementation of the above method with some examples :
Example 1 :
Python3
import turtle
print (turtle.undobufferentries())
turtle.setundobuffer( 10 )
for i in range ( 50 ):
turtle.forward( 1 )
print (turtle.undobufferentries())
|
Output :
0
10
Example 2 :
Python3
import turtle
print (turtle.undobufferentries())
for i in range ( 50 ):
turtle.fd( 1 )
print (turtle.undobufferentries())
turtle.setundobuffer( None )
print (turtle.undobufferentries())
|
Output :
0
50
0
Share your thoughts in the comments
Please Login to comment...