【发布时间】:2017-09-08 18:58:42
【问题描述】:
我目前正在使用 Cling(C++ 解释器),它是 jupyter 内核,我想使用类似于 IPython.display 的某种 C++ 函数在 Jupyter notebook 中显示图像。 最好的方法是什么?
更新
感谢您的回复,我目前正在研究这两个选项,以检查 Windows 上的版本多少比较稳定,并且可能会在下周返回(目前还有很多其他工作正在进行),每个选项都有 cmets。
【问题讨论】:
我目前正在使用 Cling(C++ 解释器),它是 jupyter 内核,我想使用类似于 IPython.display 的某种 C++ 函数在 Jupyter notebook 中显示图像。 最好的方法是什么?
更新
感谢您的回复,我目前正在研究这两个选项,以检查 Windows 上的版本多少比较稳定,并且可能会在下周返回(目前还有很多其他工作正在进行),每个选项都有 cmets。
【问题讨论】:
该功能需要在内核级别实现,也就是说,如果 cling 本身没有给你逃生舱,你可能做不到。
从技术上讲,当您显示某些内容时,cling 将发送一个display_data 消息,其中包含一个 mimebundle(一种映射表单 mimetype 到数据),因此您需要挂钩到内核本身来执行此操作。
我不相信它还在 Cling 中,尽管 QuantStack 的人最近在 JupyterCon 上做了一个演示(视频尚未在线),他们在他们的 Xeus-Cling 内核中展示了 widgets。
因此,我强烈建议您尝试 xeus-cling,并询问那里的开发人员(在 GitHub 上打开问题,或尝试他们响应的 Gitter 频道)。
【讨论】:
这可以满足您的需要吗?来自 cling/tools/Jupyter/Kernel.cpp:
/// Push MIME stuff to Jupyter. To be called from user code.
///\param contentDict - dictionary of MIME type versus content. E.g.
/// {{"text/html", {"<div></div>", }}
///\returns `false` if the output could not be sent.
bool pushOutput(const std::map<std::string, MIMEDataRef> contentDict) {
【讨论】: