Python vispy.app.Timer() Examples

The following are 5 code examples of vispy.app.Timer(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module vispy.app , or try the search function .
Example #1
Source File: base.py    From p5 with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, setup_method, draw_method,
                 handlers=dict(), frame_rate=60):
        app.Canvas.__init__(
            self,
            title=builtins.title,
            size=(builtins.width, builtins.height),
            keys='interactive',
            resizable=True,
        )

        self.setup_method = setup_method
        self.draw_method = draw_method

        self.looping = None
        self.redraw = None
        self.setup_done = False
        self.timer = app.Timer(1.0 / frame_rate, connect=self.on_timer)

        self.handlers = dict()
        for handler_name in handler_names:
            self.handlers[handler_name] = handlers.get(handler_name, _dummy)

        self.handler_queue = []

        self._save_fname = 'screen'
        self._save_fname_num = 0
        self._save_flag = False

        p5.renderer.initialize_renderer()
        p5.renderer.clear() 
Example #2
Source File: shadertoy-render.py    From shadertoy-render with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def ensure_timer(self):
        if not self._timer:
            self._timer = app.Timer('auto' if self._ffmpeg_pipe else self._interval,
                                    connect=self.on_timer,
                                    start=True) 
Example #3
Source File: tools.py    From glue-vispy-viewers with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def __init__(self, viewer):
        super(RecordTool, self).__init__(viewer=viewer)
        self.record_timer = app.Timer(connect=self.record)
        self.writer = None
        self.next_action = 'start' 
Example #4
Source File: tools.py    From glue-vispy-viewers with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def activate(self):
        if self.timer is None:
            self.timer = app.Timer(connect=self.rotate)
        self.timer.start(0.1) 
Example #5
Source File: canvas.py    From harvesters_gui with Apache License 2.0 4 votes vote down vote up
def __init__(
            self, *,
            image_acquirer=None,
            width=640, height=480,
            display_rate=30.,
            background_color='gray',
            vsync=True
    ):
        """
        As far as we know, Vispy refreshes the canvas every 1/30 sec at the
        fastest no matter which faster number is specified. If we set any
        value which is greater than 30, then Vispy's callback is randomly
        called.
        """

        #
        app.Canvas.__init__(
            self, size=(width, height), vsync=vsync, autoswap=True
        )

        #
        self._ia = image_acquirer

        #
        self._background_color = background_color
        self._has_filled_texture = False
        self._width, self._height = width, height

        #
        self._is_dragging = False

        # If it's True, the canvas keeps image acquisition but do not
        # draw images on the canvas:
        self._pause_drawing = False

        #
        self._origin = [0, 0]

        #
        self._display_rate = display_rate
        self._timer = app.Timer(
            1. / self._display_rate, connect=self.update, start=True
        )

        #
        self._buffers = []