def test_schedule_once_draw_before(self): from kivy.clock import Clock Clock.schedule_once(callback, -1) Clock.tick_draw() self.assertEqual(counter, 1) Clock.tick() self.assertEqual(counter, 1)
async def async_idle(self): '''Identical to :meth:`idle`, but instead used when running within an async event loop. ''' # update dt await Clock.async_tick() # read and dispatch input from providers self.dispatch_input() # flush all the canvas operation Builder.sync() # tick before draw Clock.tick_draw() # flush all the canvas operation Builder.sync() window = self.window if window and window.canvas.needs_redraw: window.dispatch('on_draw') window.dispatch('on_flip') # don't loop if we don't have listeners ! if len(self.event_listeners) == 0: Logger.error('Base: No event listeners have been created') Logger.error('Base: Application will leave') self.exit() return False return self.quit
def idle(self): '''This function is called every frames. By default : * it "tick" the clock to the next frame * read all input and dispatch event * dispatch on_update + on_draw + on_flip on window ''' # update dt Clock.tick() # read and dispatch input from providers self.dispatch_input() window = self.window if window and window.canvas.needs_redraw: Clock.tick_draw() window.dispatch('on_draw') window.dispatch('on_flip') # don't loop if we don't have listeners ! if len(self.event_listeners) == 0: Logger.error('Base: No event listeners have been created') Logger.error('Base: Application will leave') self.exit() return False return self.quit
def test_unschedule_draw(self): from kivy.clock import Clock Clock.schedule_once(callback, 0) Clock.tick_draw() self.assertEqual(counter, 0) Clock.unschedule(callback) Clock.tick() self.assertEqual(counter, 0)
def idle(self): '''This function is called after every frame. By default: * it "ticks" the clock to the next frame. * it reads all input and dispatches events. * it dispatches `on_update`, `on_draw` and `on_flip` events to the window. ''' # update dt Clock.tick() # read and dispatch input from providers if not self.quit: self.dispatch_input() # flush all the canvas operation if not self.quit: Builder.sync() # tick before draw if not self.quit: Clock.tick_draw() # flush all the canvas operation if not self.quit: Builder.sync() if not self.quit: window = self.window if window and window.canvas.needs_redraw: window.dispatch('on_draw') window.dispatch('on_flip') # don't loop if we don't have listeners ! if len(self.event_listeners) == 0: Logger.error('Base: No event listeners have been created') Logger.error('Base: Application will leave') self.exit() return False return self.quit
def idle(self): '''This function is called after every frame. By default: * it "ticks" the clock to the next frame. * it reads all input and dispatches events. * it dispatches `on_update`, `on_draw` and `on_flip` events to the window. ''' # update dt Clock.tick() # read and dispatch input from providers self.dispatch_input() # flush all the canvas operation Builder.sync() # tick before draw Clock.tick_draw() # flush all the canvas operation Builder.sync() window = self.window if window and window.canvas.needs_redraw: window.dispatch('on_draw') window.dispatch('on_flip') # don't loop if we don't have listeners ! if len(self.event_listeners) == 0: Logger.error('Base: No event listeners have been created') Logger.error('Base: Application will leave') self.exit() return False return self.quit
def _clock_sandbox_draw(self, dt): Clock.tick_draw() Builder.sync() self.main_clock.schedule_once(self._call_draw, 0)