Initializes process and starts simulation loops.
(self, master, width, height)
| 87 | ######################################################################## |
| 88 | |
| 89 | def __init__(self, master, width, height): |
| 90 | "Initializes process and starts simulation loops." |
| 91 | super().__init__(master) |
| 92 | canvas = tkinter.Canvas(self, width=width, height=height, |
| 93 | background='white', highlightthickness=0) |
| 94 | canvas.bind('<1>', self.mouse_pressed) |
| 95 | canvas.grid() |
| 96 | graphics = Graphics(canvas) |
| 97 | self.setup(graphics.fill) |
| 98 | render = 1 / self.RENDER_EACH_SECOND |
| 99 | update = 1 / self.UPDATE_EACH_SECOND |
| 100 | self.__loop(lambda: self.render(graphics), render, time.clock(), 0) |
| 101 | self.__loop(lambda: self.update(update), update, time.clock(), 0) |
| 102 | |
| 103 | def __loop(self, method, interval, target, errors): |
| 104 | "Runs the method after each interval has passed." |