MCPcopy Create free account
hub / github.com/ActiveState/code / __init__

Method __init__

recipes/Python/578004_processing/recipe-578004.py:89–101  ·  view source on GitHub ↗

Initializes process and starts simulation loops.

(self, master, width, height)

Source from the content-addressed store, hash-verified

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."

Callers

nothing calls this directly

Calls 8

setupMethod · 0.95
__loopMethod · 0.95
renderMethod · 0.95
updateMethod · 0.95
GraphicsClass · 0.85
__init__Method · 0.45
bindMethod · 0.45
gridMethod · 0.45

Tested by

no test coverage detected