I am writing a custom JupyterLab extension that should receive a callback whenever an output changes.
For example, the following code creates a simple button that increases a counter and prints the current count to the output.
import ipywidgets as widgets output = widgets.Output() button = widgets.Button(description="Counter") counter = 0 def handle_click(button): global counter counter += 1 with output: print(counter) button.on_click(handle_click) display(button) display(output)
In the extension, I want to access the output widget to listen to changes.
Currently, I can get the actual code cell output, which is just the widget object, as shown in the following image:
Is there a possibility to get a callback based on this information (e.g., model id)?
Maybe using the module @jupyter-widgets/base? I did not find any documentation for this module.