Begin by opening a window and using two mouse clicks to draw a circle, where the
ID: 3654613 • Letter: B
Question
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!!! 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!! 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. Add another prompt and Entry object so that the user can also enter the outline color for the circle.Explanation / Answer
In graphIntro.py, a prompt to end the graphics program appeared in the Shell window, requiring you to pay attention to two windows. Instead consider a very simple example program, face.py, where all the action takes place in the graphics window. The only interaction is to click the mouse to close the graphics window. In Windows, have a directory window open to the Python examples folder containing face.py, where your operating system setup may allow you be just double click on the icon for face.py to run it. If that does not work on your system, you can always run from inside Idle. After you have checked out the picture, click with the mouse inside the picture, as requested, to terminate the program. After you have run the program, you can examine the program in Idle or look below. The whole program is shown first; smaller pieces of it are discussed later: '''A simple graphics example constructs a face from basic shapes. ''' from graphics import * def main(): win = GraphWin('Face', 200, 150) # give title and dimensions win.yUp() # make right side up coordinates! head = Circle(Point(40,100), 25) # set center and radius 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)) # set endpoints eye2.setWidth(3) eye2.draw(win) mouth = Oval(Point(30, 90), Point(50, 85)) # set corners of bounding box mouth.setFill("red") mouth.draw(win) label = Text(Point(100, 120), 'A face') label.draw(win) message = Text(Point(win.getWidth()/2, 20), 'Click anywhere to quit.') message.draw(win) win.getMouse() win.close() main()
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.