def idle(self): dt = clock.tick(False) # Redraw all windows for window in windows: if window.invalid: window.switch_to() window.dispatch_event('on_draw') window.flip() # Update timout return clock.get_sleep_time(True)
def idle(self): '''Called during each iteration of the event loop. The method is called immediately after any window events (i.e., after any user input). The method can return a duration after which the idle method will be called again. The method may be called earlier if the user creates more input events. The method can return `None` to only wait for user events. For example, return ``1.0`` to have the idle method called every second, or immediately after any user events. The default implementation dispatches the `pyglame.window.Window.on_draw` event for all windows and uses `pyglame.clock.tick` and `pyglame.clock.get_sleep_time` on the default clock to determine the return value. This method should be overridden by advanced users only. To have code execute at regular intervals, use the `pyglame.clock.schedule` methods. :rtype: float :return: The number of seconds before the idle method should be called again, or `None` to block for user input. ''' dt = clock.tick(True) # Redraw all windows for window in windows: if window.invalid: window.switch_to() window.dispatch_event('on_draw') window.flip() # Update timout return clock.get_sleep_time(True)