Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine the window size turtle python setup

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?

like image 426
Mamunur Rashid Avatar asked Apr 03 '18 08:04

Mamunur Rashid


People also ask

How do you change the size of a turtle window in Python?

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'.

Which function is used to set the size of the turtle window?

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


1 Answers

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.

like image 84
cdlane Avatar answered Sep 30 '22 16:09

cdlane