ipylab

1.1.0 · active · verified Thu Apr 16

ipylab is a Python library that allows direct control and interaction with the JupyterLab environment from within Python notebooks. It provides programmatic access to JupyterLab's features, enabling users to add widgets to the main area, build complex interfaces using Lumino widgets, launch arbitrary commands, and listen to JupyterLab signals to trigger Python callbacks. The library is currently at version 1.1.0 and is actively maintained with a focus on compatibility with recent JupyterLab and ipywidgets versions.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to instantiate the JupyterFrontEnd application object and use it to execute a JupyterLab command. A button is created using `ipywidgets`, which, when clicked, triggers the 'notebook:run-all-below' command in the active JupyterLab notebook.

from ipylab import JupyterFrontEnd
import ipywidgets as widgets
from IPython.display import display

app = JupyterFrontEnd()

def run_all(event):
    """Executes the 'notebook:run-all-below' command in JupyterLab."""
    print("Executing 'notebook:run-all-below'...")
    app.commands.execute('notebook:run-all-below')
    print("Command sent.")

button = widgets.Button(description="Run All Below")
button.on_click(run_all)

display(button)

view raw JSON →