The Wayback Machine - https://web.archive.org/web/20240201172802/https://www.geeksforgeeks.org/turtle-screensize-function-in-python/
Open In App
Related Articles

turtle.screensize() function in Python

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

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 :


Don't miss your chance to ride the wave of the data revolution! Every industry is scaling new heights by tapping into the power of data. Sharpen your skills and become a part of the hottest trend in the 21st century.

Dive into the future of technology - explore the Complete Machine Learning and Data Science Program by GeeksforGeeks and stay ahead of the curve.


Last Updated : 26 Jul, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials