October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk2 min

Python Turtle Background: Set a Color, Hex or RGB Value, or Image

Use Python Turtle’s bgcolor() for solid colors and bgpic() for image backgrounds, with examples for names, hex, RGB, and image paths.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use screen.bgcolor(...) to set a solid Python Turtle background and screen.bgpic(...) to display an image. The color method accepts color strings, hex values, and RGB input; numeric RGB values must match the screen’s color mode.

Change the Python Turtle background color

Create a Turtle screen, then pass the color to bgcolor(). The method accepts a Tk color specification string, an RGB tuple, or three RGB arguments.

As an Amazon Associate I earn from qualifying purchases.

import turtle

screen = turtle.Screen()
screen.bgcolor("lightblue")
turtle.done()

Color names such as "lightblue" and hex strings such as "#800080" are string inputs. Use whichever format is clearest for your code.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a hex color in Turtle

Pass the hex color as a string to bgcolor():

import turtle

screen = turtle.Screen()
screen.bgcolor("#800080")
turtle.done()

The official Python 3.14.7 reference uses "#800080" as an example and shows that the screen reports it as the RGB tuple (128.0, 0.0, 128.0) when read back. Python turtle.bgcolor() reference

Set an RGB background color

You can pass RGB components as a tuple or as three separate arguments. The allowed component range depends on screen.colormode(), which is either 1.0 or 255; each component must be within the selected range.

import turtle

screen = turtle.Screen()
screen.colormode(255)
screen.bgcolor((128, 0, 128))
# Equivalent: screen.bgcolor(128, 0, 128)
turtle.done()

With the default 1.0 mode, use component values from 0 to 1 instead. Set the mode deliberately before supplying numeric components so the values use the range you expect. Python turtle.colormode() reference

Add a background image to Turtle

Use bgpic() with the image filename or path. The Python 3.14.7 reference documents PNG, GIF, PGM, and PPM formats.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import turtle

screen = turtle.Screen()
screen.bgpic("landscape.gif")
turtle.done()

The file needs to be available at the path your program supplies. If it does not appear, check that the path resolves from the running program and that the file uses a documented format; behavior can depend on the installed environment. Python turtle.bgpic() reference

To remove the current background image, call screen.bgpic("nopic"). Calling screen.bgpic() without an argument returns the current image name.

Color or image: which method should you use?

What you want Method Input
Flat background bgcolor() Color name, hex string, RGB tuple, or three RGB arguments
Picture behind the drawing bgpic() Local image filename or path in PNG, GIF, PGM, or PPM format

These methods serve different purposes: bgcolor() sets a solid color, while bgpic() sets a background image.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Reapply the background after a reset

Turtle’s documented reset state has a white background and no background image. If a screen reset clears your chosen background, call bgcolor() or bgpic() again after the reset. Python turtle.Screen reference

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.