Let's play:
class Window:
def __init__(self, x, y):
global app
app = self
def event(self, func):
self.what_todo = func
def run(self):
self.what_todo()
>>> game_window = Window(800, 600)
>>>
>>> @game_window.event
... def on_draw():
... print("I am drawing!")
...
>>> app.run()
I am drawing!
>>>
Of course, they probably are doing things a bit differently, but I hope you get the basic idea.