Using IPyWidgets

Nextjournal’s Jupyter runtimes support rendering standard ipywidgets and Plotly Figure Widgets. Widget support is currently experimental so the following caveats apply:

  • Widgets need an active Jupyter runtime to show. This means your widgets will show inside the editor but not in the read-only version of you notebook.

  • In contrast to the Jupyter security model, we currently don’t allow arbitrary Javascript execution in a widget’s HTML output. Depending on your widget, some features might not work because of this limitation.

Setup

Using IPyWidgets requires setting up your runtime as Jupyter runtime. This is likely already the case if you started your notebook by importing an existing Jupyter notebook. If that’s not the case, open your Python runtime’s settings dialog and select Jupyter under Type:

Once changed, be sure to restart your runtime via the runner menu or press Alt+Shift+R. If you find that the menu item is disabled, make sure your cursor is inside a Python code cell.

Once your runtime has restarted, you can start implementing your widgets.

Widget Demos

Remix the following notebook to play around with some widget examples:

👉 Demo: IPyWidgets