| 25 | build_graph() |
| 26 | |
| 27 | def build_graph(): |
| 28 | # Build GUI environment. |
| 29 | global graph |
| 30 | root = Tk() |
| 31 | if WINDOWED: |
| 32 | root.resizable(False, False) |
| 33 | root.title('Boids') |
| 34 | else: |
| 35 | root.overrideredirect(True) |
| 36 | x = (root.winfo_screenwidth() - WIDTH) / 2 |
| 37 | y = (root.winfo_screenheight() - HEIGHT) / 2 |
| 38 | root.geometry('%dx%d+%d+%d' % (WIDTH, HEIGHT, x, y)) |
| 39 | root.bind_all('<Escape>', lambda event: event.widget.quit()) |
| 40 | graph = Canvas(root, width=WIDTH, height=HEIGHT, background='white') |
| 41 | graph.after(1000 / FRAMES_PER_SEC, update) |
| 42 | graph.pack() |
| 43 | |
| 44 | def update(): |
| 45 | # Main simulation loop. |