Streamlined program interface.
2 from caugrid import Grid
5 def __init__(self, title, width, height):
9 self.root = tk.Tk(className=title, sync=1)
10 self.canvas = tk.Canvas(width=self.width, height=self.height, bg="black")
11 self.canvas.pack(expand=tk.YES, fill=tk.BOTH)
12 def render(self, grid):
13 offset = (self.width / 2, self.height / 2)
16 for pos in grid.cells.iterkeys():
17 x = pos[0] + offset[0]
18 y = pos[1] + offset[1]
19 cell_id = self.canvas.create_rectangle(x, y, x+size, y+size,
20 fill="yellow", width=0)
21 cell_ids.append(cell_id)
23 for cell_id in cell_ids:
24 self.canvas.delete(cell_id)
28 import caumarshal as marshal
32 filename = sys.argv[1]
33 print "rendering ", filename
34 render = Render("hope", 1000, 1000)
37 current = os.stat(filename)[stat.ST_MTIME]
38 if current > mod_time:
40 print "updating render"
42 grid = marshal.loadGrid(filename)
44 except IndexError, ValueError:
48 if __name__ == "__main__":