-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
integrate with ipython event loop #674
Comments
I use it with simple example using https://github.com/pygfx/pygfx/edit/main/examples/feature_demo/geometry_image.py import imageio.v3 as iio
from wgpu.gui.auto import WgpuCanvas, run
import pygfx as gfx
canvas = WgpuCanvas()
renderer = gfx.renderers.WgpuRenderer(canvas)
scene = gfx.Scene()
im = iio.imread("imageio:astronaut.png")[:, :, 1].copy()
image = gfx.Image(
gfx.Geometry(grid=gfx.Texture(im, dim=2)),
gfx.ImageBasicMaterial(clim=(0, 255)),
)
scene.add(image)
camera = gfx.OrthographicCamera(512, 512)
camera.local.position = (256, 256, 0)
camera.local.scale_y = -1
def animate():
renderer.render(scene, camera)
canvas.request_draw()
canvas.request_draw(animate) And then change stuff: image.material.clim = (50, 250)
image.geometry.grid.data[::2, ::2] = 255
image.geometry.grid.update_range((0, 0, 0), image.geometry.grid.size) |
Hi @schlegelp! Thanks for reporting this! It's definitely our intention to work well in interactive environments, but things indeed don't seem very smooth yet on IPython,
This is probably because it calls the I would also expect |
Actually the glfw backend is non blocking without any magic commands (at least in jupyter on my end). 🤔 If you use |
It looks like this is not the case in IPython (from the terminal) though. Even when I The goal is that From what I can see now we need some work in these areas:
|
Looked at this with the example I posted above:
If it helps my ipython package versions, I'm on latest pygfx@main, wgpu-py v0.14.1 (release)
|
Hi all, Coming from Fastplotlib and following Kushal advice, I am posting this error I have on my Mac when trying to use Using python 3.11, setup is
I tried to do : import fastplotlib as fpl
plot = fpl.Plot(canvas='glfw')
|
The issues will be resolved in pygfx/wgpu-py#478. In particular, glfw runs as expected, and in Jupyter the Unfortunately, it is not possible to use the glfw backend interactively in IPython. IPython does have some sort of asyncio support, but only runs a loop briefly when calling code with On The PR also adds docs that explain what I just said. |
Closing, as the pr is merged. See the docs here: https://wgpu-py.readthedocs.io/en/latest/gui.html#using-wgpu-interactively |
Thanks! |
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 takepygfx
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. Forpygfx
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 withpygfx
or more like on the side ofPyQt6
. FWIW, I also triedglfw
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:
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
The text was updated successfully, but these errors were encountered: