Right now, there is an implicit, but not explict, link in the code between the canvas manager and the canvases, so any algorithm that tries to trace widget dependencies misses that the canvas manager is associated with each canvas. This makes that association explicit (as a bonus, allows a person to create multiple canvas managers if they so desire, I suppose).
This fixes a problem we have with ipycanvas in the Databricks notebook. In the Databricks notebook, we isolate widgets to individual iframes, and only create widget models for widgets that are explicitly referenced. Since the CanvasManager was not referenced from any canvas (only an implicit association in the Python code), we wouldn't ever create a CanvasManager frontend object in the iframe with the Canvas. This PR makes this association explicit, so algorithms (like ours) that rely on explicit associations between widgets to create them from a single root widget will work. This also helps in the algorithm we've thought about in the past to serialize a tree of widgets to a notebook, in that the algorithm can now find the correct explicitly associated CanvasManager object.
Right now, there is an implicit, but not explict, link in the code between the canvas manager and the canvases, so any algorithm that tries to trace widget dependencies misses that the canvas manager is associated with each canvas. This makes that association explicit (as a bonus, allows a person to create multiple canvas managers if they so desire, I suppose).
This fixes a problem we have with ipycanvas in the Databricks notebook. In the Databricks notebook, we isolate widgets to individual iframes, and only create widget models for widgets that are explicitly referenced. Since the CanvasManager was not referenced from any canvas (only an implicit association in the Python code), we wouldn't ever create a CanvasManager frontend object in the iframe with the Canvas. This PR makes this association explicit, so algorithms (like ours) that rely on explicit associations between widgets to create them from a single root widget will work. This also helps in the algorithm we've thought about in the past to serialize a tree of widgets to a notebook, in that the algorithm can now find the correct explicitly associated CanvasManager object.