turtle.Screen().setup() method - Python Last Updated : 22 Mar, 2025 Comments Improve Suggest changes Like Article Like Report setup() method in Python's turtle module is used to set up the size and position of the turtle graphics window before drawing. By default, the turtle window appears in the center of the screen with a standard size, but setup() allows customization.Example: Setting a Fixed Window Size Python import turtle sc = turtle.Screen() sc.setup(width=600, height=400) # Window size: 600x400 pixels sc.bgcolor("pink") turtle.done() Output: Explanation: Here, we create a turtle graphics screen and set its dimensions to 600 pixels wide and 400 pixels high. The bgcolor("pink") function changes the background color to pink. The turtle.done() function ensures the window remains open.Syntax of setup() turtle.Screen().setup(width=None, height=None, startx=None, starty=None)Parameters:ParameterDescriptionwidthDefines the window's width in pixels or as a fraction of the screen width.height Sets the window's height in pixels or as a fraction of the screen height.startxSpecifies the x-coordinate for the window's top-left corner (in pixels).starty Specifies the y-coordinate for the window's top-left corner (in pixels).Note:width and height can be given as absolute values (pixels) or as fractions of the screen size (e.g., 0.5 means 50% of the screen).startx and starty define the position of the window’s top-left corner. If not provided, the window is centered.Examples of turtle.Screen().setup() Example 1: Setting Window Size and Position with Color Python import turtle screen = turtle.Screen() screen.setup(width=500, height=300, startx=100, starty=150) screen.bgcolor("lightblue") # Set background color turtle.done() Output: Explanation: In this example, we set the window size to 500x300 pixels and position it at (100,150) on the screen. The startx=100 and starty=150 parameters define the top-left corner’s coordinates. The background color is set to light blue.Example 2: Using Fractions of the Screen Size with Color Python import turtle screen = turtle.Screen() screen.setup(width=0.5, height=0.5) # 50% of screen width and height screen.bgcolor("lightgreen") # Set background color turtle.done() Output: Explanation: Here, the width and height are set to 0.5, meaning the window occupies 50% of the total screen size in both dimensions. This makes it adaptable to different screen resolutions. The background color is set to light green. Comment More infoAdvertise with us Next Article turtle.Screen().setup() method - Python D deepanshu_rustagi Follow Improve Article Tags : Python Python-turtle Practice Tags : python Similar Reads turtle.right() method 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.right() The turtle.right() method is used to change the direction of the tur 2 min read turtle.screensize() function in Python The turtle.screensize() function in Python's turtle module is used to set or retrieve the size of the drawing canvas (the area where the turtle moves and draws). This function helps in customizing the workspace according to user requirements.Example: Checking default screen sizePythonimport turtle # 2 min read turtle.Screen().turtles() 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.Screen().turtles() This function is used to return the list of turtles on th 1 min read turtle.reset() 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.reset() This function is used to delete the turtle's drawings and restore it 1 min read turtle.up() method 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.up() The turtle.up() method is used to pull the pen up from the screen. It g 1 min read Python - turtle.delay() method Turtle graphics is a popular way for introducing programming to kids. It was part of the original Logo programming language developed by Wally Feurzeig, Seymour Papert and Cynthia Solomon in 1967. The turtle module provides turtle graphics primitives, in both object-oriented and procedure-oriented w 1 min read turtle.pos() method 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.pos() This method is used to find the turtle's current location (x, y), as a 2 min read turtle.resetscreen() 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.resetscreen() This function is used to reset all Turtles on the Screen to th 1 min read turtle.down() method 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.down() The turtle.down() method is used to pull back the pen down on the scr 1 min read turtle.left() method 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.left() The turtle.left() method is used to change the direction of the turtl 2 min read Like