473,387 Members | 3,684 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Click to display

15
Expand|Select|Wrap|Line Numbers
  1. from graphics import *
  2. import math
  3. def drawCircle(win, centre, radius, colour):
  4.     circle = Circle(centre, radius)
  5.     circle.setFill(colour)
  6.     circle.setWidth(2)
  7.     circle.draw(win)
  8.  
  9. def drawEye(win, centre):
  10.     for circles in range(1):
  11.         drawCircle(win, centre, 50, "white")
  12.         drawCircle(win, centre, 20, "blue")
  13.         drawCircle(win, centre, 10, "black")
  14. def click():    
  15.     win=GraphWin("eye",300, 300)
  16.     centre = Point(150,150)
  17.     for i in range(1):
  18.         drawCircle(win, centre , 100, "white")
  19.         drawCircle(win, centre, 50, "yellow")
  20.         drawCircle(win, centre, 25, "black")
  21.         p = win.getMouse()
  22.             iris1x=130
  23.     iris1y=130
  24.     iris2x=170
  25.     iris2y=170
  26.     pupil1x=110
  27.     pupil2x=190
  28.     pupil1y=110
  29.     pupil2y=190
  30.     sclera1x=50
  31.     sclera2x=250
  32.     sclera1y=50
  33.     sclera2y=250
  34.     clickx=p.getX()
  35.     clicky=p.getY()
  36.     while True:
  37.         if clickx>=iris1x and clickx <=iris2x and clicky>=iris1y and clicky<=iris2y:
  38.             message = Text(Point(200,280), "pupil")
  39.             message.draw(win)
  40.         elif clickx>=pupil1x and clickx<=pupil2x and clicky>=pupil1y and clicky<=pupil2y:
  41.             message = Text(Point(150,280), "Iris")
  42.             message.draw(win)
  43.         elif clickx>=white1x and clickx<=white2x and clicky>=white1y and clicky<=white2y:
  44.             message= Text(Point(150,280), "white")
  45.             message.draw(win)
  46.         else:
  47.             win.close()
Hello
I am quite stuck on a python exercise and not quite sure how to finish it.
My task is to draw an eye using a graphics module, and when the user clicks the mouse on the eye, the program is to specify what part of the eye was clicked on, so either the pupil, white or iris, and to continue this until the user clicks outside the eye to quit the window. I have sort of managed this but I can't get it to repeat. If anyone could help me get this to work and simplify it I would be greatly thankful.
Nov 26 '09 #1
1 1854
Glenton
391 Expert 256MB
What does your code do when you run it at the moment?
Dec 2 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Sally | last post by:
I need to be able to click in a subform and run code but at the same time I need to be able to scroll the records without running the code. I tried coding the Enter event of the subform control but...
11
by: Terry Olsen | last post by:
How can I catch a right-click on a DropDownMenuItem?
10
by: rajbala | last post by:
Hai all, I need to get two or three images as a buttons.At the moment when i click the image it must display on window if i click another image button that image also display on the same...
1
by: rajbala.3399 | last post by:
Hai all, I need to get multiple image buttonsand wheni click on the image button it should display corresponding image on window and if i click another image button it is also display on same...
8
by: =?Utf-8?B?UmljaA==?= | last post by:
My from contains a "Move Next" button. When the user clicks on the "Move Next" button - several procedures get invoked and eventually, the dataset underlying the form will display main data from...
12
by: Ste | last post by:
Hi there, I've got a website with a list of Frequently Asked Questions, so there's a question and answer in a long list down the page. Can anyone recommend a simple script that would allow me...
1
by: liesther2003 | last post by:
Hi i want to show mutli layer by each click, and when i click next layer the first layer should be still display, until maybe 3rd or 4th or 5th layer all are displayed, and at the end when i click...
2
by: duke123 | last post by:
Hi, I have two divs (image & story) both positioned in a manner so that one overlays the other. The purpose of the code below is to hide one and show the other on a button click. So whenever we...
0
by: ajanu81 | last post by:
hi all, i am new to this forum. i am using a windows application using C#. I am using a datagridview to display contents of a xml file. say i have a xml file like this. <xml version="1.0"...
3
by: timplx | last post by:
Hello all, New to javascript and have never worked with programming languages like c++, so my logic in some of these statements might be incorrect or redundant Got a problem with my page......
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.