When using the turtle module in Python, we can change the turtle screen size dimensions with the screensize() function.
import turtle
turtle.screensize(canvwidth=550, canvheight=350)
The turtle module in Python allows us to create graphics easily in our Python code.
We can use the turtle module to make all sorts of graphics in Python. For example, we can draw triangles and draw squares easily in Python with the turtle module.
When working with the turtle module, sometimes it makes sense to want to change the size of the turtle screen.
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’.
Below is an example how to change the size of the turtle window to have a width of 550 pixels and a height of 350 pixels in Python.
import turtle
turtle.screensize(canvwidth=550, canvheight=350)
What is the Default turtle Screen Size in Python?
When working with the turtle module, we might want to change the screen size back to the default screen dimensions.
The default screen size dimensions for turtle is a width of 400 pixels and a height of 300 pixels.
If you’d like to go back to the default window size, you can call the screensize() function and pass ‘canvwidth=400’ and ‘canvheight=300’.
Below is an example in Python of how to change the turtle window dimensions back to the default screen size.
import turtle
turtle.screensize(canvwidth=400, canvheight=300)
How to Change the Background Color of the turtle Screen using Python
We can also change the background color of the turtle screen with the screensize() function.
To change the background color of the turtle screen, you can use the ‘bg’ argument and pass any valid turtle color.
Below is an example of how to change the turtle screen background color in Python.
import turtle
turtle.screensize(bg="red")
Hopefully this article has been useful for you to change the Python turtle screen size.