Jupyter widgets vs JupyterLab Extension?

Viewed 950

I know that JupyterLab is the next-generation web-based UI for Project Jupyter and it's based on the Jupyter Notebook and Architecture, and it will eventually replace the classic Jupyter Notebook.

I am a bit confused about the differences and relationships between Jupyter widgets and JupyterLab Extensions:

  • Will JupyterLab Extensions eventually replace those Jupyter widgets for using interactive Notebook?

  • Is Jupyter Widgets only for classic Jupyter Notebook? Or is Widgets just one type of the Extensions for JupyterLab?

1 Answers

I'm not an expert on Jupyter extensions, but I think the following is accurate (please correct me if someone knows otherwise).

Jupyter widgets are actually implemented using an extension.

The main difference between widgets and other extensions is that the Python kernel in a notebook can easily interact with a widget -- the kernel can "call in" to the widget and the widget can "call back" to the kernel. For example the kernel can change the text label for a button in the widget and a button press on the widget can cause Python code to execute in the kernel.

For example the following notebook creates a widget with a click callback to python which calls back to Javascript to change the appearance of the widget:

https://github.com/AaronWatters/jp_proxy_widget/blob/master/notebooks/hello%20proxy%20world.ipynb

Extensions do not automatically build in ways for a Python kernel process in a notebook to interact with the extension instance, although it is possible to implement them.

Related