Skip to content

Embedding in PyQt #340

Description

@joeyo

Here is a minimal example example that should work with Qt:

import fastplotlib as fpl
plot = fpl.Plot(canvas="qt")
plot.show()

if __name__ == "__main__":
    fpl.run()

With these packages installed:

wgpu==0.11.0
pygfx==0.1.15
fastplotlib==0.1.0a13
PyQt6==6.5.3

the following error message is generated (similar errors occur with PyQt5, PySide2, and PySide6):

Traceback (most recent call last):
  File "/Users/joeyo/src/bmi/analysis/joeyo/fpl/qt_minimal.py", line 3, in <module>
    plot = fpl.Plot(canvas="qt")
  File "/opt/homebrew/lib/python3.10/site-packages/fastplotlib/layouts/_plot.py", line 54, in __init__
    super(Plot, self).__init__(
  File "/opt/homebrew/lib/python3.10/site-packages/fastplotlib/layouts/_subplot.py", line 77, in __init__
    canvas, renderer = make_canvas_and_renderer(canvas, renderer)
  File "/opt/homebrew/lib/python3.10/site-packages/fastplotlib/layouts/_utils.py", line 50, in make_canvas_and_renderer
    raise ImportError(
ImportError: The qt framework is not installed for using this canvas

Which suggests that fastplotlib/layouts/_utils.py:17 is raising an ImportError:

16 try:
17    from wgpu.gui.qt import QWgpuCanvas
18 except ImportError:
19    QWgpuCanvas = False

However the following will run without errors:

import PyQt6  # apparently necessary
from wgpu.gui.qt import QWgpuCanvas

Is there some missing import logic?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions