Graphics Module

You are welcome to look over the code in graphics.py, but do not worry about the details of the implementation. More information about the library can be found here. In your code, you will (minimally) make use of the following methods from this module:

Graphics Function or Method

Behavior

GraphWin(title, width, height)

Constructs a new graphics window (or GraphWin) for drawing on the screen. The parameters are optional; the default title is “Graphics Window,” and the default size is 200 x 200 pixels.
Example: win = GraphWin("Boggle", 400, 400)

getMouse()

Pauses (or blocks) and waits for the user to click their mouse in the window and returns where the mouse was clicked as a Point object (a tuple, with x and y values).
Example: clickPoint = win.getMouse()

Point(x, y)

Constructs a Point having the given coordinates.
Example: aPoint = Point(3.5, 8)

pt.getX() and pt.getY()

Returns the x and y coordinate of a Point, respectively.
Example: xVal = aPoint.getX() and yVal = aPoint.getY()

Rectangle(point1, point2)

Constructs a Rectangle having opposite corners at point1 (top left) and point2 (bototm right).
Example: aRect = Rectangle(Point(1, 3), Point(4, 7))

Text(anchorPoint, textString)

Constructs a Text object that displays textString centered at anchorPoint. The text is displayed horizontally.
Example: message = Text(Point(3,4), "Hello!")

txt.setText(string)

Sets the text of the Text object to string.
Example: message.setText("Goodbye!")

txt.getText()

Gets the text of the Text object (as a string).
Example: var = message.getText()

txt.setTextColor(color)

Sets the color of the Text to color (a string). Note: setFill(color) has the same effect on Text objects.
Example: message.setTextColor("pink")

txt.getTextColor()

Gets the color of the Text (as a string). Note: setFill(color) has the same effect on Text objects.
Example: message.setTextColor("pink")

Feel free to check out the documentation for other methods that you may find helpful as you customize your implementation.

Acknowledgement

The graphics package was originally copied from here.