Search code examples
c++ipythonjupytercling

Jupyter: how to implement image viewing functionality in new kernel


I'm currently playing with Cling(C++ interpreter) and it's jupyter kernel and I would want to display an image inside Jupyter notebook using some kind of C++ function similar to IPython.display. What would be the best approach for that?

Update

Thanks for replies, I'm currently digging into both options to check what has a somewhat stable release on Windows and will be back probably next week(a lot of other work at hand right now) with comments on each of it.


Solution

  • The feature need to be implemented at the kernel level, that is to say, if cling itself does not give you the escape hatch to do it, you likely cant.

    Technically under the hood, when you display something, cling will send a display_data message, which contain a mimebundle (a mapping form mimetype to data), so you need to hook into the kernel itself to do so.

    I don't believe it is in Cling yet, though the QuantStack folks did a demo recently at JupyterCon (video not online yet) where they showed widgets in their Xeus-Cling kernel.

    I would thus strongly encourage you to try xeus-cling, and ask the developers there (open an issue on GitHub, or try the Gitter channel they are responsive).