Jan-Hendrik Müller
Jan-Hendrik Müller•4mo ago

Running marimo with the 3d image viewer napari?

Hi there! I was thinking of running marimo with napari. In a classic notebook in VS Code, I can simply run
pip install "napari[pyqt5]"
pip install "napari[pyqt5]"
import napari
from skimage import data

cells = data.cells3d()
viewer = napari.view_image(cells, channel_axis=1)
import napari
from skimage import data

cells = data.cells3d()
viewer = napari.view_image(cells, channel_axis=1)
and it opens the viewer for me (screenshot 1) When I run the same notebook in marimo, I don't get any error, but the window does not pop up. Interestingly though, the napari viewer icon pops at the right side of the screen (and I also get this jumping icon animation), but when I click it, nothing happens (screenshot2). I'm on a MacBook Air M3.
No description
No description
4 Replies
Jan-Hendrik Müller
Jan-Hendrik MüllerOP•4mo ago
@Myles Scolnick , @Akshay : I've just reached out to the napari community, and they pointed me to this link explaining their qt event loop https://napari.org/stable/guides/event_loop.html#in-ipython-or-jupyter-notebook I don't know too much about qt event loops, but maybe you can figure out how to incorperate the event loop with marimo. Would be really fun to use the 3D image viewer napari without callbacks! 🙂
No description
Jan-Hendrik Müller
Jan-Hendrik MüllerOP•4mo ago
and another observation:
import napari
from skimage import data

cells = data.cells3d()
viewer = napari.view_image(cells, channel_axis=1)
napari.run()
import napari
from skimage import data

cells = data.cells3d()
viewer = napari.view_image(cells, channel_axis=1)
napari.run()
opens the viewer successfully, but also it blocks marimo execution until I close the napari window.
No description
Akshay
Akshay•4mo ago
Mm interesting — I wasn’t aware that IPython had a gui event loop. I wonder if we can hook into it somehow or otherwise reimplement its API.
Akshay
Akshay•4mo ago
@Jan-Hendrik Müller , I've created a GitHub issue to track this: https://github.com/marimo-team/marimo/issues/1986 I don't plan on adding support for the GUI event loop very soon, just because of other priorities, but I certainly see why it's important.
GitHub
GUI Event Loop integration · Issue #1986 · marimo-team/marimo
Description GUI libraries such as napari rely on IPython's opt-in integration with GUI event loops to render and respond to user interactions. We currently have no support for integrating with ...