Exemplo n.º 1
0
def test_interactive():
    f = MockApp()
    set_interactive(enabled=True, app=f)

    assert inputhook_manager._current_gui == 'vispy'
    assert f._in_event_loop
    assert 'vispy' in inputhook_manager.apps
    assert f == inputhook_manager.apps['vispy']

    set_interactive(enabled=False)

    assert inputhook_manager._current_gui is None
    assert not f._in_event_loop
Exemplo n.º 2
0
    def on_draw(self, event):
        gloo.clear(color=True)

    def on_timer(self, event):
        # Animation speed based on global time.
        t = event.elapsed
        c = Color(self.color).rgb
        # Simple sinusoid wave animation.
        s = abs(0.5 + 0.5 * math.sin(t))
        self.context.set_clear_color((c[0] * s, c[1] * s, c[2] * s, 1))
        self.update()


# You should run this demo as main with ipython -i <file>.  If interactive
# mode is not specified, this demo will exit immediately because this demo
# doesn't call run and relies on the input hook being setup.
if __name__ == '__main__':
    from vispy import app
    # app.use_app('glfw')  # for testing specific backends
    app.set_interactive()


# All variables listed in this scope are accessible via the console.
canvas = Canvas(keys='interactive')
canvas.show()


# In IPython, try typing any of the following:
#   >>> canvas.color = (1.0, 0.0, 0.0)
#   >>> canvas.color = 'red'
Exemplo n.º 3
0
        self.color = 'white'

    def on_draw(self, event):
        gloo.clear(color=True)

    def on_timer(self, event):
        # Animation speed based on global time.
        t = event.elapsed
        c = Color(self.color).rgb
        # Simple sinusoid wave animation.
        s = abs(0.5 + 0.5 * math.sin(t))
        gloo.set_clear_color((c[0] * s, c[1] * s, c[2] * s, 1))
        self.update()


# You should run this demo as main with ipython -i <file>.  If interactive
# mode is not specified, this demo will exit immediately because this demo
# doesn't call run and relies on the input hook being setup.
if __name__ == '__main__':
    from vispy import app
    # app.use_app('glfw')  # for testing specific backends
    app.set_interactive()

# All variables listed in this scope are accessible via the console.
canvas = Canvas(keys='interactive')
canvas.show()

# In IPython, try typing any of the following:
#   >>> canvas.color = (1.0, 0.0, 0.0)
#   >>> canvas.color = 'red'