""" Used in support of nks.py by K. Urner """ # from Dr. Zelle's graphics library from graphics import GraphWin, Point, Rectangle class Canvas(object): def __init__(self, width, rows, pixelsize): self.pixelsize = pixelsize self.c = GraphWin('NKS',width*pixelsize, rows*pixelsize, False) self.c.setBackground('black') def drawcell(self, thepoint): therow = thepoint[0]*self.pixelsize thecol = thepoint[1]*self.pixelsize therect = Rectangle(Point(therow, thecol), Point(therow + self.pixelsize-1, thecol + self.pixelsize-1)) therect.setFill('yellow') therect.setOutline('yellow') therect.draw(self.c) def showimage(self): self.c.flush() g = raw_input("Hit Enter on this line to close window") self.c.close()