cmarlett at luc.edu
Thu Mar 13 15:54:51 CET 2008
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...
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
eye1 = Circle(Point(30, 105), 5)
eye2 = Line(Point(45, 105), Point(55, 105)) # set endpoints
mouth = Oval(Point(30, 90), Point(50, 85)) # set corners of bounding box
message = Text(Point(winWidth/2, 20), 'Click anywhere to quit.')
I'm struggling with the Circle, however. This is what I have so far, but it won't work.
winWidth = 300
winHeight = 300
win = GraphWin('Draw a Circle', winWidth, winHeight)
win.setCoords(0, 0, winWidth, winHeight)
message = Text(Point(winWidth/2, 20), 'Click on six points')
# Get and draw six points of circle
p1 = win.getMouse()
p2 = win.getMouse()
p3 = win.getMouse()
p4 = win.getMouse()
p5 = win.getMouse()
p6 = win.getMouse()
points = [p1, p2, p3, p4, p5, p6]
# Use Oval object to draw the circle
Circle = Oval(points)
Circle.setWidth(4) # width of boundary line
# Wait for another click to exit
message.setText('Click anywhere to quit.')
Any advice you have would help out a lot. Thank you for your time.
More information about the Tutor