Lab 13

Lab Index  Course Home Page

Task 1,  Boolean Function:

Using the between function from class, complete the function definition below.  Recall that you can obtain diagonally opposite corner points of a rectangle with the getP1 and getP2 methods, and individual coordinates of a Point with getX and getY. The x and y coordinates of pt need to be between the cooresponding coordinates for the two corner points.

def inside(rect, pt):
    """ Return true if pt is on or inside rect.
    rect is a Rectangle and
    pt is a Point
    """

Task 2, Button 

Complete the function makeButton::

def makeButton(x, y, width, height, label, color, win ):
    """Create, draw, and return a rectangle with a label in the middle.
    x and y are coordinates of a corner
    width and height are the dimensions of the rectangle
    label is the text to go in the middle
    color is the inside color for the button.
    win is the GraphWin to draw in.
    """

Task 3, Buttons that Work

Write a program to use the first two tasks.  Create three buttons, one labled Quit.  When a click is inside a button, have the program do what the button says.  Quit when there is a click outside the first two buttons (inside Quit not required).  For example, draw a Circle, then have Up and Down buttons.  Move the circle according to which button is pressed. 

Lab Index  Course Home Page