简体   繁体   中英

Is there a way can set the background color for python turtle?

I am trying to set the background color of my turtle graphic, is there a way can set the background color for python turtle?

Use turtle.bgcolor(*args) .

For instance:

import turtle  
turtle.bgcolor("black")

or

from turtle import *
bgcolor("black")

Read the documentation at http://docs.python.org/library/turtle.html#turtle.bgcolor

It sounds like you set the color for your turtle, not your screen. A screen will appear even if you don't set up your screen, but then it's not defined so you can't customize it. If you set up the beginning of your code, then you can customize your screen, for example:

import turtle
wn=turtle.Screen()
wn.bgcolor("black")
wn.title("This is my screen title!")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM