How to Change Python Turtle Screen Size

I was working on a Python Turtle project where I needed to create a larger canvas for a complex drawing. The default screen size was too small for what I had in mind. The issue is, there’s no obvious way to adjust the Turtle screen size when you’re first starting with this module.

In this article, I’ll cover five simple methods you can use to change the Python Turtle screen size (some using direct properties and others using window configuration).

Methods to Change Python Turtle Screen Size

Now, I will explain to you the methods to change the Python Turtle screen size.

Method 1 – Use the setup() Function

Python’s setup() function is the easy way to set the Turtle screen size. It allows you to specify both the width and height of the window.

Here’s how you can use it:

import turtle

# Create a turtle screen
screen = turtle.Screen()

# Set the screen size to 800x600 pixels
screen.setup(width=400, height=400)

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

# Draw something
t.forward(100)

# Keep the window open
turtle.mainloop()

You can see the output in the screenshot below.

turtle screen size

The setup() function takes two main parameters:

  • width: The width of the window in pixels
  • height: The height of the window in pixels

You can also specify the position of the window on your screen using optional parameters:

# Position the window 100 pixels from the left and 50 from the top
screen.setup(width=800, height=600, startx=100, starty=50)

Method 2 – Use screensize() Function

The screensize() function is different from setup(). While setup() changes the window size, screensize() changes the area that the turtle can draw on (the canvas size).

import turtle

screen = turtle.Screen()

# Set the canvas size to 1000x800 pixels
screen.screensize(1000, 800)

# Create a turtle
t = turtle.Turtle()

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

turtle.mainloop()

You can see the output in the screenshot below.

screensize turtle

With this method, if your drawing is larger than the visible window, scrollbars will appear automatically to navigate the canvas.

Read Python Turtle Cheat Sheet

Method 3 – Combine setup() and screensize()

For complete control, you can use both functions together. This approach is particularly useful for complex projects:

import turtle

screen = turtle.Screen()

# Set the window size
screen.setup(width=800, height=600)

# Set the canvas size (can be larger than the window)
screen.screensize(1200, 1000)

# Set background color
screen.bgcolor("light blue")

t = turtle.Turtle()
t.pensize(3)

# Now you can draw on a large canvas within a defined window
for i in range(36):
    t.forward(300)
    t.right(170)

turtle.mainloop()

You can see the output in the screenshot below.

turtle size python

This gives you a window of 800×600 pixels with a drawing area of 1200×1000 pixels, meaning you’ll get scrollbars to navigate the full drawing.

Check out Python Turtle Background

Method 4 – Use window_width() and window_height()

You can also get the current window dimensions using the window_width() and window_height() methods, which is useful when you need to make calculations based on the screen size:

import turtle

screen = turtle.Screen()

# Set the initial screen size
screen.setup(width=800, height=600)

# Get the current dimensions
width = screen.window_width()
height = screen.window_height()

print(f"Current window dimensions: {width}x{height}")

# Draw something that uses the screen dimensions
t = turtle.Turtle()
t.penup()
t.goto(-width/2 + 50, height/2 - 50)  # Position near top-left corner
t.pendown()
t.write(f"Screen size: {width}x{height}", font=("Arial", 16, "normal"))

turtle.mainloop()

This is particularly useful for creating responsive drawings that adjust to different screen sizes.

Read Python Turtle Hide

Method 5 – Use TK Window Manager

For advanced control, you can access the underlying Tkinter window and modify it directly:

import turtle

screen = turtle.Screen()
canvas = screen.getcanvas()
root = canvas.winfo_toplevel()

# Set the window title
root.title("My Custom Turtle Window")

# Make the window resizable
root.resizable(True, True)

# Set minimum and maximum sizes
root.minsize(400, 300)
root.maxsize(1200, 900)

# Set window size
root.geometry("900x700")

t = turtle.Turtle()
t.shape("turtle")

# Draw a spiral
for i in range(100):
    t.forward(i * 2)
    t.right(90)

turtle.mainloop()

This method gives you access to all the Tkinter window properties, allowing for fine-grained control over your application’s appearance.

Check out Python Turtle Random

Fullscreen Mode and Other Useful Screen Properties

If you want to go full screen, you can use the following approach:

import turtle

screen = turtle.Screen()

# Set fullscreen mode
screen.setup(1.0, 1.0)  # This sets the window to 100% of screen width and height

# Alternatively, you can use:
# canvas = screen.getcanvas()
# root = canvas.winfo_toplevel()
# root.attributes("-fullscreen", True)

t = turtle.Turtle()
t.speed(0)  # Fastest speed

# Draw a colorful pattern that fills the screen
colors = ["red", "purple", "blue", "green", "yellow", "orange"]
for i in range(360):
    t.pencolor(colors[i % 6])
    t.width(i // 100 + 1)
    t.forward(i)
    t.left(59)

turtle.mainloop()

You can also control other screen properties such as:

# Set a background image
screen.bgpic("background.gif")

# Change the background color
screen.bgcolor("black")

# Hide the turtle
t.hideturtle()

# Increase the drawing speed
t.speed(0)  # 0 is the fastest speed

I hope you found this article helpful. When working with Python Turtle, adjusting the screen size is often necessary for creating more complex or detailed drawings. The methods I’ve shared give you different options depending on your specific needs.

Whether you need a precise window size, a large drawing canvas, or full control over the window properties, Python Turtle provides the flexibility to customize your drawing environment.

Other Python articles you may also like:

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.