[Tutor] Hello

Greg Graham GGraham at cistercian.org
Thu Mar 13 17:17:57 CET 2008


It appears to me that the following line would not work:
>    Circle = Oval(points)

The variable "points" is a list of six points, and I don't know how one
would define a circle or oval with 6 points. At the top part of your
program, an oval is defined using two points, which makes sense. 

Maybe you should use two of the points for the outline of the face, one
point for each eye, and two for the mouth, which amounts to 6 points
total.

Greg


-----Original Message-----
From: tutor-bounces at python.org [mailto:tutor-bounces at python.org] On
Behalf Of Christopher Marlett
Sent: Thursday, March 13, 2008 9:55 AM
To: tutor at python.org
Subject: [Tutor] Hello

Hi, I'm in a Python class and we were given the assignment to create our
own graphic and my idea was to have a program that asks the user to
click six points and then create a circle using the six points they
clicked. Once they've done that I want eyes and a mouth to appear in the
circle. I was wondering if that was possible or if I need to have them
also click the points where the two eyes and nose should appear as well.
I have the face written, it looks like this...
def main():
    winWidth = 200  # give a name to the window width
    winHeight = 150 #    and height
    win = GraphWin('Face', winWidth, winHeight) # give title and
dimensions
    win.setCoords(0, 0, winWidth, winHeight) # make right side up
coordinates!

    head = Circle(Point(40,100), 25) # set center and radius
    head.setFill("yellow")
    head.draw(win)

    eye1 = Circle(Point(30, 105), 5)
    eye1.setFill('blue')
    eye1.draw(win)

    eye2 = Line(Point(45, 105), Point(55, 105)) # set endpoints
    eye2.setWidth(3)
    eye2.draw(win)

    mouth = Oval(Point(30, 90), Point(50, 85)) # set corners of bounding
box
    mouth.setFill("red")
    mouth.draw(win)

    message = Text(Point(winWidth/2, 20), 'Click anywhere to quit.')
    message.draw(win)
    win.getMouse()
    win.close()

main()

I'm struggling with the Circle, however. This is what I have so far, but
it won't work.

def main():
    winWidth = 300
    winHeight = 300
    win = GraphWin('Draw a Circle', winWidth, winHeight)
    win.setCoords(0, 0, winWidth, winHeight)
    win.setBackground('yellow')
    message = Text(Point(winWidth/2, 20), 'Click on six points')
    message.draw(win)

    # Get and draw six points of circle
    p1 = win.getMouse()
    p1.draw(win)
    p2 = win.getMouse()
    p2.draw(win)
    p3 = win.getMouse()
    p3.draw(win)
    p4 = win.getMouse()
    p4.draw(win)
    p5 = win.getMouse()
    p5.draw(win)
    p6 = win.getMouse()
    p6.draw(win)
    points = [p1, p2, p3, p4, p5, p6]

    # Use Oval object to draw the circle
    Circle = Oval(points)
    Circle.setFill('green')
    Circle.setOutline('pink')
    Circle.setWidth(4) # width of boundary line
    Circle.draw(win)

    # Wait for another click to exit
    message.setText('Click anywhere to quit.')
    message.setTextColor('red')
    message.setStyle('italic')
    message.setSize(20)
    win.getMouse()
    win.close()
Any advice you have would help out a lot. Thank you for your time. 
_______________________________________________
Tutor maillist  -  Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor


More information about the Tutor mailing list