How to use the vispy.app.run function in vispy

To help you get started, we’ve selected a few vispy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github janpipek / physt / examples / test_vispy.py View on Github external
from physt import h2, h3, plotting
from physt.plotting import vispy as vp
import numpy as np
from matplotlib import pyplot as plt
from vispy import app

data = np.random.normal(0, 10, (1000, 3))
print(data)

H = h3(data)
vp.voxel(H)

if __name__ == '__main__':
    app.run()

"""
# -*- coding: utf-8 -*-
github vispy / vispy / examples / demo / gloo / atom.py View on Github external
self.update()

    def on_draw(self, event):
        gloo.clear('black')
        self.program.draw('points')

    def apply_zoom(self):
        width, height = self.physical_size
        gloo.set_viewport(0, 0, width, height)
        self.projection = perspective(45.0, width / float(height), 1.0, 1000.0)
        self.program['u_projection'] = self.projection


if __name__ == '__main__':
    c = Canvas()
    app.run()
github vispy / vispy / examples / basics / visuals / reactive_regular_polygon.py View on Github external
self.rpolygon.radius = 80.
        self.rpolygon.sides = 4
        self.rpolygon.color = 'red'
        self.update()

    def on_draw(self, ev):
        gloo.clear(color='black')
        gloo.set_viewport(0, 0, *self.size)
        self.draw_visual(self.rpolygon)
        

if __name__ == '__main__':
    win = Canvas() 
    import sys
    if sys.flags.interactive != 1:
        vispy.app.run()
github vispy / vispy / examples / howto / arcball-rotate.py View on Github external
-float(vec[1])/self.size[1]*2.0 + 1.0, 0.0],
                          dtype=np.float32)
        result2 = np.linalg.norm(result)

        if result2 <= 1:
            result[2] = math.sqrt(1 - result2)
        else:
            result = result/result2

        return result


if __name__ == '__main__':
    c = Canvas()
    c.show()
    app.run()
github vispy / vispy / examples / basics / gloo / display_shape.py View on Github external
gloo.set_clear_color('white')

        self.show()

    def on_resize(self, event):
        width, height = event.physical_size
        gloo.set_viewport(0, 0, width, height)

    def on_draw(self, event):
        gloo.clear()
        self._program.draw('triangle_strip')


if __name__ == '__main__':
    c = Canvas()
    app.run()
github vispy / vispy / examples / demo / gloo / cloud.py View on Github external
self.update()

    def on_draw(self, event):
        gloo.clear()
        self.program.draw('points')

    def apply_zoom(self):
        gloo.set_viewport(0, 0, self.physical_size[0], self.physical_size[1])
        self.projection = perspective(45.0, self.size[0] /
                                      float(self.size[1]), 1.0, 1000.0)
        self.program['u_projection'] = self.projection


if __name__ == '__main__':
    c = Canvas()
    app.run()
github vispy / vispy / examples / basics / visuals / rescalingmarkers.py View on Github external
def on_key_press(self, event):
        if event.text == ' ':
            self.index = (self.index + 1) % (len(impl_visuals.marker_types))
            self.markers.symbol = impl_visuals.marker_types[self.index]
            self.text.text = impl_visuals.marker_types[self.index]
            self.update()


canvas = Canvas()
grid = canvas.central_widget.add_grid()
vb1 = grid.add_view(row=0, col=0)
vb1.add(canvas.markers)

if __name__ == '__main__':
    canvas.show()
    app.run()
github vispy / vispy / examples / tutorial / visuals / T03_antialiasing.py View on Github external
tr = visuals.transforms.MatrixTransform()
tr.rotate(25, (0, 0, 1))
rects[1].transform = tr

# Add some text instructions
text = scene.visuals.Text("Drag right mouse button to zoom.", 
                          color='w',
                          anchor_x='left',
                          parent=view,
                          pos=(20, 30))

# ..and optionally start the event loop
if __name__ == '__main__':
    import sys
    if sys.flags.interactive != 1:
        app.run()
github vispy / vispy / examples / tutorial / app / simple.py View on Github external
self._timer = app.Timer('auto', connect=self.on_timer, start=True)
        self.tick = 0

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

    def on_timer(self, event):
        self.tick += 1 / 60.0
        c = abs(math.sin(self.tick))
        gloo.set_clear_color((c, c, c, 1))
        self.update()

if __name__ == '__main__':
    canvas = Canvas(keys='interactive', always_on_top=True)
    canvas.show()
    app.run()
github vispy / vispy / examples / basics / gloo / start_shaders.py View on Github external
data = np.random.uniform(-0.5, 0.5, size=(20, 2))
        self.program['a_position'] = data.astype(np.float32)

    def on_resize(self, event):
        width, height = event.size
        gloo.set_viewport(0, 0, width, height)

    def on_draw(self, event):
        gloo.clear('white')
        self.program.draw('points')

if __name__ == '__main__':
    c = Canvas()
    c.show()
    if sys.flags.interactive != 1:
        app.run()