In Python 3+, I am trying to run turtle.setup(400, 500)
but it is not working.
There is no reference named setup
.
How can I use the screen setup in Python 3?
We can easily change the size of the turtle screen in Python with the screensize() function, and pass integer values to the arguments 'canvwidth' and 'canvheight'.
screensize() This method is used to resize the canvas the turtles are drawing on. If no arguments are given, this function returns the current (canvaswidth, canvasheight).
There are (at least) three options depending on how you import turtle. Going from worst to best:
Option 1:
from turtle import *
setup(400, 500)
Option 2:
import turtle
turtle.setup(400, 500)
Option 3:
from turtle import Turtle, Screen
screen = Screen()
screen.setup(400, 500)
If these don't work for you, then update your question with more information about the environment under which you're running Python/turtle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With