Question: PYTHON: TO DO #1: The main() function Write a Python main() function that takes no arguments and returns nothing. This function should create a Graphics
PYTHON:
TO DO #1: The main() function
Write a Python main() function that takes no arguments and returns nothing. This function should create a Graphics Window, of size 400 X 400 pixels. Set the background to light grey. Create a blue circle(radius 30) in the center of the Graphics Window.
TO DO #2: Animating the Circles movement
Edit your main() function, so that it now waits for the user to click anywhere within the Graphics window. Once a mouse click is detected, the Circle should move from its current location to the location of the mouse click.
You have two options here with the opportunity to earn either 2 or 4 points on TODO #2:
The Circle disappears and reappears in the location of the mouse click (2 points)
The Circle moves smoothly across the window to the mouse click location (4 points)
Whichever animation option you use, the user should be able to click to move the Circle five (5) times, after which a message should appear "Click to Exit". One further click anywhere on the Window should close it and end the program.
This is what I have so far:
# import graphics and math
from graphics import *
from math import *
# Define main()
def main():
# Create graphics window
>>>win=GraphWin('Window',400,400)
>>>clickPoint=win.getMouse()
# Create blue cirle, with radius 30 in center of graphics window
>>>circle=Circle(Point(200,200),30)
>>>color=['blue']
>>>circle.setFill(color)
>>>circle.draw(win)
# Move circle to mouse click, five times
>>>for i in range(0,5):
# Display message Click to Exit
>>>message.setText("Click to Exit")
# Use the getMouse() function to wait for a mouse click in the Graphics
# window.
>>>win.getMouse()
# Close window
>>>win.close()
# Call main()
main()
How do I make the circle move?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
