Welcome to Dream.In.Code
Getting Help is Easy!

Join 131,514 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,853 people online right now. Registration is fast and FREE... Join Now!




Draw Image Upon Mouse Click

 
Reply to this topicStart new topic

Draw Image Upon Mouse Click

Lseifert
post 8 Oct, 2008 - 11:01 AM
Post #1


New D.I.C Head

*
Joined: 8 Oct, 2008
Posts: 1

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.

CODE

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()


User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/20/08 12:51AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month