Question:
Write a program implementing basic graphic functionalities such as draw,getMouse, circle etc
Program:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
from graphics import * win = GraphWin() #win is an instance of a window to display graphics content pt= Point(100,100) #pt is an object which is a Point on the screen and its co-ordinates on screen is (100,50) pt.draw(win) #the Point object pt is displayed on the screen win.getMouse() #listens for mouse click inside the window to proceed to next statement execution e = Circle(pt, 50) #e is a Circle object with centre as a Point object pt and radius 5 e.setFill('yellow') #fills blue color in the Circle object e e.draw(win) #displays the circle object win.getMouse() win.close() #closes the current GraphWin window |
Explanation:
Graphic Functionalities are implemented in python by importing graphics.py
Output:
Leave a Reply