在Jupyter Notebook中嵌入幻灯片

时间:2018-07-26 20:23:17

标签: python jupyter-notebook

我想要一种类似于python的方式将幻灯片显示嵌入到jupyter笔记本单元格中,类似于此处的幻灯片显示:

https://www.w3schools.com/howto/howto_js_slideshow.asp

我不需要任何CSS样式,除了下一个/上一个幻灯片箭头外,不需要任何其他按钮。

我不想将整个笔记本变成一个幻灯片放映,只希望一个单元格,所以我不能使用reveal.js。

我很难相信,考虑到所有其他交互式小部件的存在,没有简单的方法可以将幻灯片放到笔记本中:

http://jupyter.org/widgets

真的没有简便的方法吗?

1 个答案:

答案 0 :(得分:0)

http://ipywidgets.readthedocs.io/en/latest/examples/Using%20Interact.html

事实证明,一旦将IntSlider聚焦(单击),就可以使用箭头键将其递增到下一个/上一个滑块值,这足以满足我的目的。这是我如何使用滑块小部件的示例:

import ipywidgets as wg
from IPython.display import SVG

def f(x):
    if x == 1:
        return SVG(filename='./path/to/pic1')
    elif x == 2:
        return SVG(filename='./path/to/pic2')
    elif x == 3:
        return SVG(filename='./path/to/pic3')
    else:
        return SVG(filename='./path/to/pic4')

wg.interact(f, x=wg.IntSlider(min=1,max=4,step=1));
相关问题