Example #1
0
 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)
Example #2
0
File: base.py Project: sonnyky/kivy
    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
Example #3
0
    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
Example #4
0
    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
Example #5
0
 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)
Example #6
0
 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)
Example #7
0
 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)
Example #8
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
Example #9
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
        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
Example #10
0
 def _clock_sandbox_draw(self, dt):
     Clock.tick_draw()
     Builder.sync()
     self.main_clock.schedule_once(self._call_draw, 0)
Example #11
0
 def _clock_sandbox_draw(self, dt):
     Clock.tick_draw()
     Builder.sync()
     self.main_clock.schedule_once(self._call_draw, 0)