Monday, April 6, 2026
HomeLanguagesturtle.screensize() function in Python

turtle.screensize() function in Python

The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented ways. Because it uses Tkinter for the underlying graphics, it needs a version of Python installed with Tk support.

turtle.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).

Syntax :

turtle.screensize(canvwidth=None, canvheight=None, bg=None)

Parameters:

Arguments Value Description
canvwidth positive integer new width of canvas in pixels
canvheight positive integer new height of canvas in pixels
bg colorstring or color-tuple new backgroundcolor

Below is the implementation of the above method with some examples :

Example 1 :

Python3




# import package
import turtle
  
  
# check the screensize by default
# it varies ide to ide
print(turtle.screensize())


Output :

(400, 300)

Example 2 :

Python3




# import package
import turtle
  
  
# set screen
turtle.screensize(canvwidth=400, canvheight=400,
                  bg="yellow")


Output :

Example 3 :

Python3




# import package
import turtle
  
# set turtle
turtle.width(2)
turtle.speed(10)
  
# loop for pattern
for i in range(10):
    turtle.circle(40)
    turtle.right(36)
  
# set screen and drawing remain as it is.
turtle.screensize(canvwidth=400, canvheight=300,
                  bg="blue")


Output :

RELATED ARTICLES

Most Popular

Dominic
32512 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6886 POSTS0 COMMENTS
Nicole Veronica
12007 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12100 POSTS0 COMMENTS
Shaida Kate Naidoo
7015 POSTS0 COMMENTS
Ted Musemwa
7260 POSTS0 COMMENTS
Thapelo Manthata
6972 POSTS0 COMMENTS
Umr Jansen
6960 POSTS0 COMMENTS