本文整理汇总了Python中vispy.app.use_app函数的典型用法代码示例。如果您正苦于以下问题:Python use_app函数的具体用法?Python use_app怎么用?Python use_app使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了use_app函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: start_qt_app
def start_qt_app():
"""Start a Qt application if necessary.
If a new Qt application is created, this function returns it.
If no new application is created, the function returns None.
"""
# Only start a Qt application if there is no
# IPython event loop integration.
if not _check_qt():
return
global _APP
if _try_enable_ipython_qt():
return
try:
from vispy import app
app.use_app("pyqt4")
except ImportError:
pass
if QtGui.QApplication.instance():
_APP = QtGui.QApplication.instance()
return
if _APP:
return
_APP = QtGui.QApplication(sys.argv)
return _APP
开发者ID:danieljdenman,项目名称:phy,代码行数:26,代码来源:qt.py
示例2: __init__
def __init__(self, retina):
app.use_app('pyglet')
self.retina = retina
app.Canvas.__init__(self, keys='interactive', fullscreen=True, size=(1280, 960))#
self.program = gloo.Program(vertex, fragment, count=4)
self.program['position'] = [(-1, -1), (-1, +1), (+1, -1), (+1, +1)]
self.program['texcoord'] = [(1, 1), (1, 0), (0, 1), (0, 0)]
self.program['texture'] = np.zeros((self.retina.h, self.retina.w, 3)).astype(np.uint8)
width, height = self.physical_size
gloo.set_viewport(0, 0, width, height)
self._timer = app.Timer('auto', connect=self.on_timer, start=True)
self.start = time.time()
self.show()
开发者ID:meduz,项目名称:openRetina,代码行数:13,代码来源:openRetina.py
示例3: main
def main():
if args.no_audio:
State.do_init(audio=False) # initialize the state objects/threads
else:
State.do_init(audio=True) # initialize the state objects/threads
app.use_app(backend_name="PyGlet")
c = Renderer()
c.show()
if args.full:
c.fullscreen = True # fullscreen mode
c.app.run()
State.destroy()
Logger.warn("Exiting VisAR")
开发者ID:jpanikulam,项目名称:visar,代码行数:14,代码来源:render_package.py
示例4: test_context_properties
def test_context_properties():
"""Test setting context properties"""
a = use_app()
if a.backend_name.lower() == 'pyglet':
return # cannot set more than once on Pyglet
# stereo, double buffer won't work on every sys
contexts = [dict(samples=4), dict(stencil_size=8),
dict(samples=4, stencil_size=8)]
if a.backend_name.lower() != 'glfw': # glfw *always* double-buffers
contexts.append(dict(double_buffer=False, samples=4))
contexts.append(dict(double_buffer=False))
else:
assert_raises(RuntimeError, Canvas, app=a,
context=dict(double_buffer=False))
if a.backend_name.lower() == 'sdl2' and os.getenv('TRAVIS') == 'true':
raise SkipTest('Travis SDL cannot set context')
for context in contexts:
n_items = len(context)
with Canvas(context=context):
if 'true' in (os.getenv('TRAVIS', ''),
os.getenv('APPVEYOR', '').lower()):
# Travis and Appveyor cannot handle obtaining these values
props = context
else:
props = get_gl_configuration()
assert_equal(len(context), n_items)
for key, val in context.items():
# XXX knownfail for windows samples, and wx (all platforms)
if key == 'samples':
iswx = a.backend_name.lower() == 'wx'
if not (sys.platform.startswith('win') or iswx):
assert_equal(val, props[key], key)
assert_raises(TypeError, Canvas, context='foo')
assert_raises(KeyError, Canvas, context=dict(foo=True))
assert_raises(TypeError, Canvas, context=dict(double_buffer='foo'))
开发者ID:jlaura,项目名称:vispy,代码行数:35,代码来源:test_context.py
示例5: _load_webgl_backend
def _load_webgl_backend(ipython):
""" Load the webgl backend for the IPython notebook"""
from vispy import app
app_instance = app.use_app("ipynb_webgl")
if app_instance.backend_name == "ipynb_webgl":
ipython.write("Vispy IPython module has loaded successfully")
else:
# TODO: Improve this error message
ipython.write_err("Unable to load webgl backend of Vispy")
开发者ID:NoriVicJr,项目名称:vispy,代码行数:11,代码来源:ipython.py
示例6: test_run
def test_run():
"""Test app running"""
a = use_app()
if a.backend_name.lower() == 'glut':
raise SkipTest('cannot test running glut') # knownfail
for _ in range(2):
with Canvas(size=(100, 100), show=True, title='run') as c:
@c.events.draw.connect
def draw(event):
print(event) # test event __repr__
c.app.quit()
c.update()
c.app.run()
c.app.quit() # make sure it doesn't break if a user quits twice
开发者ID:Zulko,项目名称:vispy,代码行数:14,代码来源:test_app.py
示例7: __init__
def __init__(self, et, timeline, downscale=1, stim_type='calibration_horizontal'):
self.downscale = downscale
self.et = et
self.timeline = timeline
img0 = np.zeros((self.window_h, self.window_w, 3)).astype(np.uint8)
app.use_app('pyglet')
app.Canvas.__init__(self, keys='interactive', size=(1280, 720))
self.fullscreen = True
self.width, self.height = self.physical_size
print ('window size : ', self.physical_size)
self.stimulation = Stimulation(self.width//downscale, self.height//downscale, stim_type=stim_type)
self.program = gloo.Program(vertex, fragment, count=4)
self.program['position'] = [(-1, -1), (-1, +1), (+1, -1), (+1, +1)]
self.program['texcoord'] = [(1, 1), (1, 0), (0, 1), (0, 0)]
self.program['texture'] = np.zeros((self.height//downscale, self.width//downscale, 3)).astype(np.uint8)
gloo.set_viewport(0, 0, self.width, self.height)
self._timer = app.Timer('auto', connect=self.on_timer, start=True)
self.start = time.time()
self.stims_X_t = []
self.native.set_mouse_visible(False)
self.show()
开发者ID:meduz,项目名称:LeCheapEyeTracker,代码行数:24,代码来源:EyeTrackerClient.py
示例8: test_fs
def test_fs():
"""Test fullscreen support"""
a = use_app()
if not a.backend_module.capability['fullscreen']:
return
assert_raises(TypeError, Canvas, fullscreen='foo')
if (a.backend_name.lower() == 'glfw' or
(a.backend_name.lower() == 'sdl2' and sys.platform == 'darwin')):
raise SkipTest('Backend takes over screen')
with use_log_level('warning', record=True, print_msg=False) as l:
with Canvas(fullscreen=False) as c:
assert_equal(c.fullscreen, False)
c.fullscreen = True
assert_equal(c.fullscreen, True)
assert_equal(len(l), 0)
with use_log_level('warning', record=True, print_msg=False):
# some backends print a warning b/c fullscreen can't be specified
with Canvas(fullscreen=0) as c:
assert_equal(c.fullscreen, True)
开发者ID:Zulko,项目名称:vispy,代码行数:19,代码来源:test_app.py
示例9: test_multiple_canvases
def test_multiple_canvases():
"""Testing multiple canvases"""
n_check = 3
app = use_app()
if app.backend_name.lower() == "glut":
raise SkipTest("glut cannot use multiple canvases")
with Canvas(app=app, size=_win_size, title="same_0") as c0:
with Canvas(app=app, size=_win_size, title="same_1") as c1:
ct = [0, 0]
@c0.events.draw.connect
def draw0(event):
ct[0] += 1
c0.update()
@c1.events.draw.connect # noqa, analysis:ignore
def draw1(event):
ct[1] += 1
c1.update()
c0.show() # ensure visible
c1.show()
c0.update() # force first draw
c1.update()
timeout = time() + 2.0
while (ct[0] < n_check or ct[1] < n_check) and time() < timeout:
app.process_events()
print((ct, n_check))
assert_true(n_check <= ct[0] <= n_check + 1)
assert_true(n_check <= ct[1] <= n_check + 1)
# check timer
global timer_ran
timer_ran = False
def on_timer(_):
global timer_ran
timer_ran = True
timeout = time() + 2.0
Timer(0.1, app=app, connect=on_timer, iterations=1, start=True)
while not timer_ran and time() < timeout:
app.process_events()
assert_true(timer_ran)
if app.backend_name.lower() == "wx":
raise SkipTest("wx fails test #2") # XXX TODO Fix this
kwargs = dict(app=app, autoswap=False, size=_win_size, show=True)
with Canvas(title="0", **kwargs) as c0:
with Canvas(title="1", **kwargs) as c1:
bgcolors = [None] * 2
@c0.events.draw.connect
def draw00(event):
print(" {0:7}: {1}".format("0", bgcolors[0]))
if bgcolors[0] is not None:
gl.glViewport(0, 0, *list(_win_size))
gl.glClearColor(*bgcolors[0])
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
gl.glFinish()
@c1.events.draw.connect
def draw11(event):
print(" {0:7}: {1}".format("1", bgcolors[1]))
if bgcolors[1] is not None:
gl.glViewport(0, 0, *list(_win_size))
gl.glClearColor(*bgcolors[1])
gl.glClear(gl.GL_COLOR_BUFFER_BIT)
gl.glFinish()
for ci, canvas in enumerate((c0, c1)):
print("draw %s" % canvas.title)
bgcolors[ci] = [0.5, 0.5, 0.5, 1.0]
_update_process_check(canvas, 127)
for ci, canvas in enumerate((c0, c1)):
print("test")
_update_process_check(canvas, 127, draw=False)
bgcolors[ci] = [1.0, 1.0, 1.0, 1.0]
_update_process_check(canvas, 255)
bgcolors[ci] = [0.25, 0.25, 0.25, 0.25]
_update_process_check(canvas, 64)
开发者ID:Zulko,项目名称:vispy,代码行数:84,代码来源:test_simultaneous.py
示例10:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
A GLSL sandbox application based on the spinning cube. Requires PySide
or PyQt4.
"""
import numpy as np
from vispy import app, gloo
from vispy.io import read_mesh, load_data_file, load_crate
from vispy.util.transforms import perspective, translate, rotate
# Force using qt and take QtCore+QtGui from backend module
try:
app_object = app.use_app("pyqt4")
except Exception:
app_object = app.use_app("pyside")
QtCore = (app_object.backend_module.QtCore,)
QtGui = app_object.backend_module.QtGui
VERT_CODE = """
uniform mat4 u_model;
uniform mat4 u_view;
uniform mat4 u_projection;
attribute vec3 a_position;
attribute vec2 a_texcoord;
varying vec2 v_texcoord;
开发者ID:bdvd,项目名称:vispy,代码行数:30,代码来源:glsl_sandbox_cube.py
示例11: _test_module_properties
def _test_module_properties(_module=None):
"""Test application module"""
if _module is None:
app = use_app()
_module = app.backend_module
# Test that the keymap contains all keys supported by vispy.
module_fname = _module.__name__.split('.')[-1]
if module_fname != '_egl': # skip keys for EGL
keymap = _module.KEYMAP
vispy_keys = keymap.values()
for keyname in dir(keys):
if keyname.upper() != keyname:
continue
key = getattr(keys, keyname)
assert_in(key, vispy_keys)
# For Qt backend, we have a common implementation
alt_modname = ''
if module_fname in ('_pyside', '_pyqt4', '_pyqt5'):
alt_modname = _module.__name__.rsplit('.', 1)[0] + '._qt'
# Test that all _vispy_x methods are there.
exceptions = (
'_vispy_get_native_canvas',
'_vispy_get_native_timer',
'_vispy_get_native_app',
'_vispy_reuse',
'_vispy_mouse_move',
'_vispy_mouse_press',
'_vispy_mouse_release',
'_vispy_mouse_double_click',
'_vispy_detect_double_click',
'_vispy_get_geometry',
'_vispy_get_physical_size',
'_process_backend_kwargs') # defined in base class
class KlassRef(vispy.app.base.BaseCanvasBackend):
def __init__(self, *args, **kwargs):
pass # Do not call the base class, since it will check for Canvas
Klass = _module.CanvasBackend
base = KlassRef()
for key in dir(KlassRef):
if not key.startswith('__'):
method = getattr(Klass, key)
if key not in exceptions:
print(key)
args = [None] * (len(getargspec(method).args) - 1)
assert_raises(NotImplementedError, getattr(base, key), *args)
if hasattr(method, '__module__'):
mod_str = method.__module__ # Py3k
else:
mod_str = method.im_func.__module__
assert_in(mod_str, (_module.__name__, alt_modname),
"Method %s.%s not defined in %s"
% (Klass, key, _module.__name__))
Klass = _module.TimerBackend
KlassRef = vispy.app.timer.TimerBackend
for key in dir(KlassRef):
if not key.startswith('__'):
method = getattr(Klass, key)
if key not in exceptions:
if hasattr(method, '__module__'):
# Py3k
assert_in(method.__module__,
(_module.__name__, alt_modname))
else:
t = method.im_func.__module__ == _module.__name__
assert t
Klass = _module.ApplicationBackend
KlassRef = vispy.app.application.ApplicationBackend
for key in dir(KlassRef):
if not key.startswith('__'):
method = getattr(Klass, key)
if key not in exceptions:
if hasattr(method, '__module__'):
# Py3k
assert_in(method.__module__,
(_module.__name__, alt_modname))
else:
t = method.im_func.__module__ == _module.__name__
assert t
# Test that all events seem to be emitted.
# Get text
fname = _module.__file__.rstrip('c') # "strip" will break windows!
with open(fname, 'rb') as fid:
text = fid.read().decode('utf-8')
canvas = vispy.app.Canvas(create_native=False, app=DummyApplication())
# Stylus and touch are ignored because they are not yet implemented.
# Mouse events are emitted from the CanvasBackend base class.
ignore = set(['stylus', 'touch', 'mouse_press', 'paint',
'mouse_move', 'mouse_release', 'mouse_double_click',
'detect_double_click', 'close'])
if module_fname == '_egl':
ignore += ['key_release', 'key_press']
eventNames = set(canvas.events._emitters.keys()) - ignore
#.........这里部分代码省略.........
开发者ID:Lx37,项目名称:vispy,代码行数:101,代码来源:test_backends.py
示例12:
# -*- coding: utf-8 -*-
"""
A GLSL sandbox application based on the spinning cube. Requires PySide
or PyQt4.
"""
from vispy.geometry.generation import create_sphere
import numpy as np
from vispy import app, gloo
from vispy.io import read_mesh, load_data_file, load_crate
from vispy.util.transforms import perspective, translate, rotate
from vispy.color import Color, ColorArray, get_colormap
from vispy.visuals.shaders import ModularProgram, Function
# Force using qt and take QtCore+QtGui from backend module
try:
app_object = app.use_app('pyqt4')
except Exception:
app_object = app.use_app('pyside')
QtCore = app_object.backend_module.QtCore,
QtGui = app_object.backend_module.QtGui
VERT_CODE = """
// Uniforms
// ------------------------------------
uniform mat4 u_model;
uniform mat4 u_view;
uniform mat4 u_projection;
uniform vec4 u_color;
// Attributes
开发者ID:ydanilin,项目名称:MinecraftMinerals,代码行数:31,代码来源:test_glsl_banded_sphere.py
示例13: canvas
1. Not showing the canvas (show=False).
2. Rendering to an FBO.
3. Manually triggering a rendering pass with self.update().
4. Retrieving the scene with _screenshot().
5. Closing the app after the first rendering pass (if that's the intended
scenario).
"""
from vispy import gloo
from vispy import app
from vispy.util.ptime import time
from vispy.gloo.util import _screenshot
# WARNING: doesn't work with Qt4 (update() does not call on_draw()??)
app.use_app('glfw')
vertex = """
attribute vec2 position;
void main()
{
gl_Position = vec4(position, 0, 1.0);
}
"""
fragment = """
uniform vec2 resolution;
uniform vec2 center;
uniform float scale;
uniform int iter;
开发者ID:Eric89GXL,项目名称:vispy,代码行数:31,代码来源:offscreen.py
示例14: cube
def cube(im_in, azimuth=30., elevation=45., name=None,
ext=ext, do_axis=True, show_label=True,
cube_label = {'x':'x', 'y':'y', 't':'t'},
colormap='gray', roll=-180., vmin=0., vmax=1.,
figsize=figsize, **kwargs):
"""
Visualization of the stimulus as a cube
"""
if not(os.path.isdir(figpath)): os.mkdir(figpath)
im = im_in.copy()
N_X, N_Y, N_frame = im.shape
fx, fy, ft = get_grids(N_X, N_Y, N_frame)
import numpy as np
from vispy import app, scene
app.use_app('pyglet')
from vispy.util.transforms import perspective, translate, rotate
canvas = scene.SceneCanvas(size=figsize, bgcolor='white', dpi=450)
view = canvas.central_widget.add_view()
# frame = scene.visuals.Cube(size = (N_X/2, N_frame/2, N_Y/2), color=(0., 0., 0., 0.),
# edge_color='k',
# parent=view.scene)
for p in ([1, 1, 1, -1, 1, 1], [1, 1, -1, -1, 1, -1], [1, -1, 1, -1, -1, 1],[1, -1, -1, -1, -1, -1],
[1, 1, 1, 1, -1, 1], [-1, 1, 1, -1, -1, 1], [1, 1, -1, 1, -1, -1], [-1, 1, -1, -1, -1, -1],
[1, 1, 1, 1, 1, -1], [-1, 1, 1, -1, 1, -1], [1, -1, 1, 1, -1, -1], [-1, -1, 1, -1, -1, -1]):
# line = scene.visuals.Line(pos=np.array([[p[0]*N_Y/2, p[1]*N_X/2, p[2]*N_frame/2], [p[3]*N_Y/2, p[4]*N_X/2, p[5]*N_frame/2]]), color='black', parent=view.scene)
line = scene.visuals.Line(pos=np.array([[p[0]*N_X/2, p[1]*N_frame/2, p[2]*N_Y/2],
[p[3]*N_X/2, p[4]*N_frame/2, p[5]*N_Y/2]]), color='black', parent=view.scene)
opts = {'parent':view.scene, 'cmap':'grays', 'clim':(0., 1.)}
image_xy = scene.visuals.Image(np.rot90(im[:, :, 0], 3), **opts)
tr_xy = scene.transforms.MatrixTransform()
tr_xy.rotate(90, (1, 0, 0))
tr_xy.translate((-N_X/2, -N_frame/2, -N_Y/2))
image_xy.transform = tr_xy
image_xt = scene.visuals.Image(np.fliplr(im[:, -1, :]), **opts)
tr_xt = scene.transforms.MatrixTransform()
tr_xt.rotate(90, (0, 0, 1))
tr_xt.translate((N_X/2, -N_frame/2, N_Y/2))
image_xt.transform = tr_xt
image_yt = scene.visuals.Image(np.rot90(im[-1, :, :], 1), **opts)
tr_yt = scene.transforms.MatrixTransform()
tr_yt.rotate(90, (0, 1, 0))
tr_yt.translate((+N_X/2, -N_frame/2, N_Y/2))
image_yt.transform = tr_yt
if do_axis:
t = {}
for text in ['x', 'y', 't']:
t[text] = scene.visuals.Text(cube_label[text], parent=canvas.scene, face='Helvetica', color='black')
t[text].font_size = 8
t['x'].pos = canvas.size[0] // 3, canvas.size[1] - canvas.size[1] // 8
t['t'].pos = canvas.size[0] - canvas.size[0] // 5, canvas.size[1] - canvas.size[1] // 6
t['y'].pos = canvas.size[0] // 12, canvas.size[1] // 2
cam = scene.TurntableCamera(elevation=35, azimuth=30)
cam.fov = 45
cam.scale_factor = N_X * 1.7
if do_axis: margin = 1.3
else: margin = 1
cam.set_range((-N_X/2, N_X/2), (-N_Y/2*margin, N_Y/2/margin), (-N_frame/2, N_frame/2))
view.camera = cam
if not(name is None):
im = canvas.render(size=figsize)
app.quit()
import vispy.io as io
io.write_png(name + ext, im)
else:
app.quit()
return im
开发者ID:egorananyev,项目名称:mc,代码行数:76,代码来源:MotionClouds.py
示例15: main
"""
__DEBUG__ = False
from math import pi
from scipy.ndimage import imread
from vispy import app
from vispy.gloo import clear, set_clear_color, set_viewport, Program
from jinja2 import Template
from wavesynlib.languagecenter.pysl.utils import hit_circle, hit_line
from wavesynlib.languagecenter.pysl.constants import pi as PI_STR
# The PyQt5 support of VisPy still has some problems.
# Hence we use the GLFW backend here.
app.use_app(backend_name='glfw')
vertex = """
#version 420
attribute vec2 position;
out vec2 texcoord;
void main(){
gl_Position = vec4(position, 0.0, 1.0 );
texcoord = position;
}
"""
开发者ID:xialulee,项目名称:WaveSyn,代码行数:31,代码来源:ppi.py
示例16: main
import numpy as np
from vispy import app, gloo
import OpenGL.GL as gl
app.use_app('pyglet') # Set backend
_vertex_code_colored = """
uniform mat4 u_mv;
uniform mat4 u_mvp;
uniform vec3 u_light_eye_pos;
attribute vec3 a_position;
attribute vec3 a_color;
varying vec3 v_color;
varying vec3 v_eye_pos;
varying vec3 v_L;
void main() {
gl_Position = u_mvp * vec4(a_position, 1.0);
v_color = a_color;
v_eye_pos = (u_mv * vec4(a_position, 1.0)).xyz; // Vertex position in eye coordinates
v_L = normalize(u_light_eye_pos - v_eye_pos); // Vector to the light
}
"""
_fragment_code_colored = """
uniform float u_light_ambient_w;
开发者ID:billow06,项目名称:ssd-6d,代码行数:29,代码来源:renderer.py
示例17: StructureCanvas
from collections import OrderedDict
from vispy import geometry
from vispy import scene
from vispy import app
from vispy import visuals
qtapp = app.use_app("pyqt4")
QtCore = qtapp.backend_module.QtCore
QtGui = qtapp.backend_module.QtGui
__class__ = ["StructureWidget", "StructureViewer"]
class StructureCanvas(scene.SceneCanvas):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
def on_close(self, event):
app.quit()
super().on_close(event)
class StructureViewer:
"""This viewer only use Vispy and automatic backend associated.
Usage
-----
>>> v = StructureViewer()
开发者ID:pombredanne,项目名称:kt_simul,代码行数:31,代码来源:viewer.py
示例18: _test_module_properties
def _test_module_properties(_module=None):
"""Test application module"""
if _module is None:
app = use_app()
_module = app.backend_module
# Test that the keymap contains all keys supported by vispy.
module_fname = _module.__name__.split(".")[-1]
if module_fname != "_egl": # skip keys for EGL
keymap = _module.KEYMAP
vispy_keys = keymap.values()
for keyname in dir(keys):
if keyname.upper() != keyname:
continue
key = getattr(keys, keyname)
assert_in(key, vispy_keys)
# For Qt backend, we have a common implementation
alt_modname = ""
if module_fname in ("_pyside", "_pyqt4"):
alt_modname = _module.__name__.rsplit(".", 1)[0] + "._qt"
# Test that all _vispy_x methods are there.
exceptions = (
"_vispy_init",
"_vispy_get_native_canvas",
"_vispy_get_native_timer",
"_vispy_get_native_app",
"_vispy_mouse_move",
"_vispy_mouse_press",
"_vispy_mouse_release",
"_vispy_get_geometry",
"_process_backend_kwargs",
) # defined in base class
Klass = _module.CanvasBackend
KlassRef = vispy.app.base.BaseCanvasBackend
base = KlassRef(None, None)
for key in dir(KlassRef):
if not key.startswith("__"):
method = getattr(Klass, key)
if key not in exceptions:
print(key)
args = [None] * (len(getargspec(method).args) - 1)
assert_raises(NotImplementedError, getattr(base, key), *args)
if hasattr(method, "__module__"):
mod_str = method.__module__ # Py3k
else:
mod_str = method.im_func.__module__
assert_in(
mod_str,
(_module.__name__, alt_modname),
"Method %s.%s not defined in %s" % (Klass, key, _module.__name__),
)
Klass = _module.TimerBackend
KlassRef = vispy.app.timer.TimerBackend
for key in dir(KlassRef):
if not key.startswith("__"):
method = getattr(Klass, key)
if key not in exceptions:
if hasattr(method, "__module__"):
# Py3k
assert_in(method.__module__, (_module.__name__, alt_modname))
else:
t = method.im_func.__module__ == _module.__name__
assert t
Klass = _module.ApplicationBackend
KlassRef = vispy.app.application.ApplicationBackend
for key in dir(KlassRef):
if not key.startswith("__"):
method = getattr(Klass, key)
if key not in exceptions:
if hasattr(method, "__module__"):
# Py3k
assert_in(method.__module__, (_module.__name__, alt_modname))
else:
t = method.im_func.__module__ == _module.__name__
assert t
# Test that all events seem to be emitted.
# Get text
fname = _module.__file__.rstrip("c") # "strip" will break windows!
with open(fname, "rb") as fid:
text = fid.read().decode("utf-8")
canvas = vispy.app.Canvas(create_native=False, app=DummyApplication())
# Stylus and touch are ignored because they are not yet implemented.
# Mouse events are emitted from the CanvasBackend base class.
ignore = set(["stylus", "touch", "mouse_press", "paint", "mouse_move", "mouse_release", "close"])
if module_fname == "_egl":
ignore += ["key_release", "key_press"]
eventNames = set(canvas.events._emitters.keys()) - ignore
if not alt_modname: # Only check for non-proxy modules
for name in eventNames:
assert_in("events.%s" % name, text, "events.%s does not appear in %s" % (name, fname))
开发者ID:Zulko,项目名称:vispy,代码行数:98,代码来源:test_backends.py
示例19: main
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
A GLSL sandbox application based on the spinning cube. Requires PySide
or PyQt4.
"""
import numpy as np
from vispy import app, gloo, dataio
from vispy.util.transforms import perspective, translate, rotate
# Force using qt and take QtCore+QtGui from backend module
app_object = app.use_app('pyqt4')
QtCore = app_object.backend_module.QtCore,
QtGui = app_object.backend_module.QtGui
VERT_CODE = """
uniform mat4 u_model;
uniform mat4 u_view;
uniform mat4 u_projection;
attribute vec3 a_position;
attribute vec2 a_texcoord;
varying vec2 v_texcoord;
void main()
{
v_texcoord = a_texcoord;
gl_Position = u_projection * u_view * u_model * vec4(a_position,1.0);
开发者ID:shjoshi,项目名称:vispy,代码行数:31,代码来源:glsl_sandbox_cube.py
示例20: Qian
Author: Penny Xuran Qian (NAOC/SAO) [email protected]
Date: Feb 15, 2016
License: GPL
Usage: running the code with 'python selection_vispy_github.py'.
press '1' or '2' to switch between view mode and selection mode for lasso method and picking method, respectively.
"""
import sys
import numpy as np
from PyQt4 import QtGui, QtCore
from vispy import app, scene
from matplotlib import path
app.use_app("pyqt4")
def rectangle_vertice(center, height, width):
# Borrow from _generate_vertices in vispy/visual/rectangle.py
half_height = height / 2.0
half_width = width / 2.0
bias1 = np.ones(4) * half_width
bias2 = np.ones(4) * half_height
corner1 = np.empty([1, 3], dtype=np.float32)
corner2 = np.empty([1, 3], dtype=np.float32)
corner3 = np.empty([1, 3], dtype=np.float32)
corner4 = np.empty([1, 3], dtype=np.float32)
开发者ID:PennyQ,项目名称:3dselection,代码行数:31,代码来源:points_selection_vispy.py
注:本文中的vispy.app.use_app函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论