code: def run(self):
          
          # pyglet.app.run() has issues like https://bitbucket.org/pyglet/pyglet/issues/199/attempting-to-resize-or-close-pyglet
          # and also involves inverting your code to run inside the pyglet framework
          # avoid both by using a while loop
          prev_frame_time = time.time()
          while True:
              self._win.switch_to()
              self._win.dispatch_events()
              now = time.time()
              self._update(now - prev_frame_time)
              prev_frame_time = now
              self._draw()
              self._win.flip()
docs: Run the interactive window until the user quits