Hi! First off: thanks for your work on this project! I'm a long-time user (and fan of) vispy which I'm using as the backend for an interactive 3d viewer in navis - the interactivity is super handy for quickly inspecting data. I've been itching to take pygfx for a spin since you started working on it and with things starting to stabilize I ran a few recently experiments. Probably preaching to the choir by saying this but the performance is out of this world! The geometries, scene setup and the example gallery in particular are very intuitive.
The one thing I've been bashing my head against is how to integrate pygfx with the ipython event loop:
What I want to be able to do is to spawn the window from an iPython terminal without blocking the REPL. For vispy it was sufficient to just run e.g. %gui qt6 to make the canvas non-blocking. For pygfx the same trick doesn't work. I tried various things based on iPython's docs on event loops but to no avail. By now I think I'm on the entirely wrong track - I'm not even sure whether the issue is with pygfx or more like on the side of PyQt6. FWIW, I also tried glfw as window manager but that doesn't seem to be playing well with ipython since it is hogging the main event loop.
Here's a minimal working example to illustrate:
# Integrate QT6 in the ipython event loop
%gui qt6
# Run the imports
from wgpu.gui.qt import WgpuCanvas
import pygfx as gfx
# Prepare something to render
cube = gfx.Mesh(
gfx.box_geometry(200, 200, 200),
gfx.MeshPhongMaterial(color="#336699"),
)
# This spawns the window and the REPL is still responsive
canvas = WgpuCanvas(size=(1000, 800))
# Initialise renderer
renderer = gfx.WgpuRenderer(canvas)
# Running `gfx.show()` starts the rendering and makes the REPL unresponsive
gfx.show(cube, canvas=canvas, renderer=renderer)
I'm probably missing something obvious but right now I'm a bit stumped and I was hoping you could point me in the right direction?
Thanks in advance!
Best,
Philipp
Hi! First off: thanks for your work on this project! I'm a long-time user (and fan of)
vispywhich I'm using as the backend for an interactive 3d viewer in navis - the interactivity is super handy for quickly inspecting data. I've been itching to takepygfxfor a spin since you started working on it and with things starting to stabilize I ran a few recently experiments. Probably preaching to the choir by saying this but the performance is out of this world! The geometries, scene setup and the example gallery in particular are very intuitive.The one thing I've been bashing my head against is how to integrate
pygfxwith the ipython event loop:What I want to be able to do is to spawn the window from an iPython terminal without blocking the REPL. For
vispyit was sufficient to just run e.g.%gui qt6to make the canvas non-blocking. Forpygfxthe same trick doesn't work. I tried various things based on iPython's docs on event loops but to no avail. By now I think I'm on the entirely wrong track - I'm not even sure whether the issue is withpygfxor more like on the side ofPyQt6. FWIW, I also triedglfwas window manager but that doesn't seem to be playing well with ipython since it is hogging the main event loop.Here's a minimal working example to illustrate:
I'm probably missing something obvious but right now I'm a bit stumped and I was hoping you could point me in the right direction?
Thanks in advance!
Best,
Philipp