Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VisPy does not work properly if QtWebEngineWidgets is imported #2577

Open
astrofrog opened this issue Feb 28, 2024 · 4 comments
Open

VisPy does not work properly if QtWebEngineWidgets is imported #2577

astrofrog opened this issue Feb 28, 2024 · 4 comments

Comments

@astrofrog
Copy link
Contributor

astrofrog commented Feb 28, 2024

I am trying to use vispy with PyQt 6.4 in an application where I also need to use QtWebEngineWidgets. This used to work fine with PyQt5 but no longer works. For example if I take the line_plot3d.py script from the examples in vispy:

import numpy as np
import sys

from vispy import app, visuals, scene

# build visuals
Plot3D = scene.visuals.create_visual_node(visuals.LinePlotVisual)

# build canvas
canvas = scene.SceneCanvas(keys='interactive', title='plot3d', show=True)

# Add a ViewBox to let the user zoom/rotate
view = canvas.central_widget.add_view()
view.camera = 'turntable'
view.camera.fov = 45
view.camera.distance = 6

# prepare data
N = 60
x = np.sin(np.linspace(-2, 2, N)*np.pi)
y = np.cos(np.linspace(-2, 2, N)*np.pi)
z = np.linspace(-2, 2, N)

# plot
pos = np.c_[x, y, z]
Plot3D(pos, width=2.0, color='red',
       edge_color='w', symbol='o', face_color=(0.2, 0.2, 1, 0.8),
       parent=view.scene)


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

I get:

Screenshot 2024-02-28 at 10 24 44

So far, so good. However, if I add an import at the top:

from qtpy import QtWebEngineWidgets  # ADDED IMPORT

import numpy as np
import sys

from vispy import app, visuals, scene

# build visuals
Plot3D = scene.visuals.create_visual_node(visuals.LinePlotVisual)

# build canvas
canvas = scene.SceneCanvas(keys='interactive', title='plot3d', show=True)

# Add a ViewBox to let the user zoom/rotate
view = canvas.central_widget.add_view()
view.camera = 'turntable'
view.camera.fov = 45
view.camera.distance = 6

# prepare data
N = 60
x = np.sin(np.linspace(-2, 2, N)*np.pi)
y = np.cos(np.linspace(-2, 2, N)*np.pi)
z = np.linspace(-2, 2, N)

# plot
pos = np.c_[x, y, z]
Plot3D(pos, width=2.0, color='red',
       edge_color='w', symbol='o', face_color=(0.2, 0.2, 1, 0.8),
       parent=view.scene)


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

Then the output is:

Screenshot 2024-02-28 at 10 26 06

I am using the latest developer version of VisPy on Python 3.11.2 on an M1 Mac.

@djhoese
Copy link
Member

djhoese commented Feb 28, 2024

I've seen this in the past with one of the various incarnations of web-widgets in the Qt space and older version of Qt (maybe 5.x). As best I remember this is usually a bug in Qt with interactions between the OpenGL widgets and the web engine widgets.

Edit: Otherwise #2570 so I won't have time for debugging this further.

@aganders3
Copy link
Contributor

@astrofrog can you post your whole env (print(vispy.sys_info())? I can't reproduce this with Python 3.11.4 + PyQt 6.6 on an M1 Mac.

@astrofrog
Copy link
Contributor Author

@aganders3 - ah this works for me too on 6.6, it didn't work on 6.4, so maybe this was indeed a Qt6 bug that has been fixed?

@aganders3
Copy link
Contributor

aganders3 commented Feb 29, 2024

That's great @astrofrog - maybe look for a Qt bug but otherwise can you close this issue if you're satisfied?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants