The library is designed to make it very easy for novice programmers to experiment with computer graphics in an object oriented fashion. It is written by John Zelle for use with the book "Python Programming: An Introduction to Computer Science" (Franklin, Beedle & Associates).
This version was modified by me to add useful features. A complete list of changes made from the original is below. Some parts of this README and the wiki in this repository are taken from here and added to/edited by me.
To install this library, put graphics.py
where it can be imported by python. It should work on any platform where Tkinter is available. It works with Python 2 and 3.
Extensive documentation is available in the wiki. Here is a complete program to draw a circle of radius 10 centered in a 100x100 window:
from graphics import *
def main():
win = GraphWin("My Circle", 100, 100) # Create a new Graphics Window with a title of "My Circle" and dimensions of 100px by 100px
c = Circle(Point(50, 50), 10) # Create a Circle object with a center point at (50, 50) and a radius of 10
c.draw(win) # Draw the circle in our window
win.getMouse() # Pause program for click in window
win.close() # Close the window at the end of the program
main()
- Add ability to determine if a
Point
is located inside aGraphicsObject
-
Rectangle
-
Circle
-
Line
-
Polygon
-
Text
-
Entry
-
Image
-
- Add ability to check where mouse cursor is
- Add ability to detect right clicks as well as left clicks
- Add chainable methods
- Add keyword arguments to
GraphicsObject
s - Add ability to rotate
GraphicsObject
s - Add ability to resize
GraphicsObject
s