How to Clear Turtle Screen in Python

I was working on a Python Turtle animation project for a class demonstration, and I needed to clear the screen between different drawing stages. The issue was, there isn’t just one way to clear the Turtle screen, and each method behaves slightly differently.

In this article, I’ll share five simple methods to clear your Python Turtle screen based on what you’re trying to accomplish.

So let’s dive in!

Methods to Clear the Turtle Screen in Python

Now, I will explain to you the methods to clear the Turtle screen in Python.

1: Use the clear() Method

Python’s clear() method is my go-to when I want to erase everything the turtle has drawn but keep the turtle in its current position and heading.

Here’s how you can use it:

import turtle

# Create a turtle object
t = turtle.Turtle()

# Draw a square
for _ in range(4):
    t.forward(100)
    t.right(90)

# Wait for 2 seconds
turtle.delay(2000)

# Clear the drawing
t.clear()

# The turtle is still in the same position
# Let's draw a triangle now
for _ in range(3):
    t.forward(100)
    t.right(120)

turtle.done()

I executed the above example code and added the screenshot below.

turtle clear screen

In this example, I first draw a square, wait for 2 seconds, and then clear the screen. Notice that the turtle stays in the same position, allowing me to draw a triangle immediately afterward.

The clear() method is perfect when you want to:

  • Keep the turtle’s position and heading
  • Only erase the drawings, not reset any other settings

2: Use the reset() Method

Sometimes I need to completely start over. That’s when the reset() method comes in handy. It clears the drawing and returns the turtle to its original position at the center.

Here’s an example:

import turtle

# Create a turtle object
t = turtle.Turtle()

# Draw a square and move away from center
for _ in range(4):
    t.forward(100)
    t.right(90)

# Wait for 2 seconds
turtle.delay(2000)

# Reset everything - clear drawing and return to center
t.reset()

# Draw a star
for _ in range(5):
    t.forward(100)
    t.right(144)

turtle.done()

I executed the above example code and added the screenshot below.

how to delete a turtle in python

The reset() method:

  • Clears the drawing
  • Returns the turtle to the center (0,0)
  • Sets heading back to the initial direction (east)
  • Resets the pen properties to default

I use this method when teaching iterations in programming to show different shapes starting from the same point.

3: Use the clearscreen() Function

When working with multiple turtles, I sometimes need to clear everything and reset all turtles. That’s where clearscreen() comes in.

import turtle

# Create two turtle objects
t1 = turtle.Turtle()
t2 = turtle.Turtle()

# Move second turtle to a different position
t2.penup()
t2.goto(100, 100)
t2.pendown()

# Draw with both turtles
t1.circle(50)
t2.circle(30)

# Wait for 2 seconds
turtle.delay(2000)

# Clear everything
turtle.clearscreen()

# Both turtles are now reset
t1.forward(100)
t2.backward(100)

turtle.done()

I executed the above example code and added the screenshot below.

turtle clear

This function is part of the turtle module rather than a method of the Turtle object. It’s particularly useful in classroom settings when I want all students to reset their screens simultaneously.

Read Fractal Python Turtle

4: Use the resetscreen() Function

Similar to clearscreen(), the resetscreen() function resets all turtles and clears the drawing area:

import turtle

# Create turtle and draw
t = turtle.Turtle()
t.speed(1)
t.color("red")
t.pensize(5)
t.forward(100)
t.left(90)
t.forward(100)

# Wait for 2 seconds
turtle.delay(2000)

# Reset the screen
turtle.resetscreen()

# The turtle returns to its default state
t.forward(100)

turtle.done()

The resetscreen() function:

  • Clears all drawings
  • Resets all turtles to their original state
  • Resets all drawing properties to default

I find this particularly useful when working on complex tutorials where I want to ensure everyone starts with the same clean slate.

Check out Python Turtle Get Position

5: Create a Custom Clear Function

For my advanced classes, I often create a custom function that combines multiple clearing operations. This gives me more control over exactly what gets reset:

import turtle

def clear_with_custom_settings(t):
    """Clear screen but keep custom speed and color"""
    current_speed = t.speed()
    current_color = t.pencolor()

    t.clear()  # Clear drawings

    # Restore custom settings
    t.speed(current_speed)
    t.pencolor(current_color)

# Create and customize turtle
t = turtle.Turtle()
t.speed(10)  # Fast speed
t.pencolor("purple")

# Draw something
for i in range(36):
    t.forward(100)
    t.right(170)

# Wait for 2 seconds
turtle.delay(2000)

# Use custom clear function
clear_with_custom_settings(t)

# Draw something new with the same settings
t.circle(100)

turtle.done()

This custom function allows me to:

  • Clear the screen
  • Preserve specific turtle settings
  • Implement more complex clearing behaviors

It’s especially useful for creating interactive applications where users can clear their drawings while maintaining certain properties.

Read Make a Smiling Face in Python Turtle

Differences Between Clear Methods

Here’s a quick comparison of the different clear methods:

MethodWhat it ClearsTurtle PositionTurtle Settings
clear()Only drawingsUnchangedUnchanged
reset()DrawingsAll return to the centerReset to default
clearscreen()All drawingsAll return to the centerAll reset to default
resetscreen()All drawingsAll return to centerAll reset to default
Custom functionCustomizableCustomizableCustomizable

Understanding these differences has helped me choose the right method for each specific situation in my projects.

Read Python Turtle Nested Loop

Practical Application: Create an Interactive Drawing Board

Let’s create a simple interactive drawing board that uses the clear screen functionality:

import turtle

# Set up the screen
screen = turtle.Screen()
screen.title("Interactive Drawing Board")
screen.setup(800, 600)

# Create drawing turtle
pen = turtle.Turtle()
pen.speed(0)
pen.pensize(3)

# Create clear button turtle
clear_button = turtle.Turtle()
clear_button.penup()
clear_button.hideturtle()
clear_button.goto(300, 250)
clear_button.write("CLEAR", font=("Arial", 16, "bold"))

# Functions
def draw(x, y):
    pen.penup()
    pen.goto(x, y)
    pen.pendown()
    pen.ondrag(pen.goto)

def clear_screen(x, y):
    # Check if the clear button was clicked
    if x > 250 and x < 350 and y > 240 and y < 270:
        pen.clear()
        pen.penup()
        pen.goto(0, 0)
        pen.pendown()

# Set up event handlers
screen.onclick(draw)
screen.onclick(clear_screen, 3)  # Right-click

# Instructions
instructions = turtle.Turtle()
instructions.penup()
instructions.hideturtle()
instructions.goto(0, -250)
instructions.write("Left-click to draw, Right-click the CLEAR button to reset", 
                   align="center", font=("Arial", 12, "normal"))

turtle.done()

This example creates a drawing board where users can:

  • Draw by clicking and dragging
  • Clear the screen by right-clicking the CLEAR button

I’ve used this in workshops to teach event-driven programming concepts.

I hope you found this article helpful in understanding the various ways to clear the Turtle screen in Python. Each method has its specific use case, and knowing when to use which one can make your Turtle graphics programming much more efficient.

You may like to read:

51 Python Programs

51 PYTHON PROGRAMS PDF FREE

Download a FREE PDF (112 Pages) Containing 51 Useful Python Programs.

pyython developer roadmap

Aspiring to be a Python developer?

Download a FREE PDF on how to become a Python developer.

Let’s be friends

Be the first to know about sales and special discounts.