Draw Image Upon Mouse Click

Page 1 of 1

0 Replies - 2115 Views - Last Post: 08 October 2008 - 12:01 PM Rate Topic: -----

#1 Lseifert  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 08-October 08

Draw Image Upon Mouse Click

Post icon  Posted 08 October 2008 - 12:01 PM

I'm trying to create a program that will duplicate an image of a face upon the user's mouse click. I'm supposed to use a simple repeat loop so a face appears for each of 6 clicks.
I've been trying to edit the repeat loop, but I'm having trouble drawing the list that makes up the face. Errors are returned every time. (Can lists even be drawn?) I also know I should use the win.getMouse() and win.close() functions, but I'm not sure as to whether they go inside the loop or outside.

from graphics import *
import time
		

def main():
	winWidth = 300
	winHeight = 300
	win = GraphWin('Faces', winWidth, winHeight)
	win.setCoords(0, 0, winWidth, winHeight)

	head = Circle(Point(40,100), 25)
	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))
	eye2.setWidth(3)
	eye2.draw(win)

	mouth = Oval(Point(30, 90), Point(50, 85))
	mouth.setFill("red")
	mouth.draw(win)

	faceList = [head, eye1, eye2, mouth]

		
	for i in range(6):
		win.getmouse()
		faceList.draw(win)
		
main()




Is This A Good Question/Topic? 0
  • +

Page 1 of 1