Class Window

class cturtle.Window(x=100, y=100, width=800, height=800)

Instances are GUI windows that support turtle graphics

You should construct a Window object before constructing a Turtle or Pen. You will only need one Window object for the entire assignment.

Constructor: creates a new Window to support turtle graphics

param x:initial x coordinate (default 100)

Precondition: int

param y:initial y coordinate (default 100)

Precondition: int

param width:initial window width (default 800)

Precondition: int

param height:initial window height (default 800)

Precondition: int

All parameters are optional.

Attributes

x

x coordinate for top left corner of window

Invariant: x must be an int

y

y coordinate for top left corner of window

Invariant: y must be an int

width

width of the window in pixels

Invariant: width must be an int

height

height of the window in pixels

Invariant: height must be an int

title

title displayed at top of window bar

Invariant: title must be a string

Immutable Attributes

These attributes may be read (e.g. used in an expression), but not altered.

turtles

list of all turtles attached to this Window

This attribute may not be altered

pens

list of all pens attached to this Window

This attribute may not be altered

Methods

clear()

Erase the contents of this Window

All Turtles and Pens are eliminated from the Window. Any attempt to use a previously created Turtle or Pen will fail.

bye()

Shut the graphics Window

Table Of Contents

Previous topic

Cornell Turtle

Next topic

Class Turtle

This Page