Use emacs to create a lab8.py in your lab8 directory.
Important Note:You need to use a different version of Python
for this lab. To run your program type:
/usr/local/bin/python2.4 lab8.py
If you run your program and see
ImportError: No module named Tkinter you need to
use the above command to run your program.
MyPaint Tips
Think about what you need to draw a circle: a center point and a radius
You should plan on using an Entry object to allow the user to
set the fill color.
Caution: When the user types the color to use into the entry box, it
is always either preceeded by or followed by a space. Since the color
name won't be recognized with leading or trailing spaces, you'll need
to strip them off. We'll make use of the string library's strip :
circle.setFill(string.strip(fill))
To detect a double-click, check to see if the two points are the same.
Step 1
Begin by opening a window and using two mouse clicks to draw a
circle, where the first mouse click is to be used as the center of
the circle and the second click is on the
edge of the circle. Just use a default circle at first (black outline).
remember to create the distance function
make sure to test your code!!!
Step 2
Put this code in a loop that stops when the two mouse clicks are in
the same position.
You will need to use "and" to compare both (first and second click) x's and y's
Test your code!!
Step 3
Next add the prompt and the Entry object to ask the user for
a fill color. Don't forget to import string at the top of
your program.
Use the stripped string the user entered to set the fill color for
the circle.
Bonus Step
Add another prompt and Entry object so that the user can
also enter the outline color for the circle.
Challenge Step
Expand your program to look loosely more like Microsoft's "Paint" program with
choices of what to draw along the left border. Allow the user to
draw circles, rectangles and lines. The user should still be allowed
to enter the outline and fill colors for the circle and rectangles.