turtle.screensize() function in Python
Last Updated :
26 Jul, 2020
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 turtle
print (turtle.screensize())
|
Output :
(400, 300)
Example 2 :
Python3
import turtle
turtle.screensize(canvwidth = 400 , canvheight = 400 ,
bg = "yellow" )
|
Output :
Example 3 :
Python3
import turtle
turtle.width( 2 )
turtle.speed( 10 )
for i in range ( 10 ):
turtle.circle( 40 )
turtle.right( 36 )
turtle.screensize(canvwidth = 400 , canvheight = 300 ,
bg = "blue" )
|
Output :
Share your thoughts in the comments
Please Login to comment...