# Objects & Graphics 1¶

## A graphics.py Tutorial¶

First, import the correct classes from the graphics module.

In [ ]:
from graphics import Point, GraphWin


We intend to draw a couple of very simple Points to a window, so let's first make our points from the Point class. The one below is positioned at $x=50$ and $y=60$.

In [ ]:
p = Point(50, 60)


Print out some helpful information about the instance of the Point class ("the Point object") we just made.

In [ ]:
print(p.getX())
print(p.getY())
print(p)
print(type(p))


We can make our shapes and use them before we even draw them. At some point when we want to draw them, we need to first make a window and have it appear.

In [ ]:
win = GraphWin()


We then ask a graphics-made object to draw itself to a window. We use the .draw(win) method. This is the action (a function, which in this context of an object is called a method) that belongs to the data of this object (the $x$ and $y$ coordinates.)

In [ ]:
p.draw(win)


Below we make a second point and then quicy draw it.

In [ ]:
p2 = Point(140,100)
p2.draw(win)