Diagram Rich Display#

The Rich Display is a good deal simpler than the Diagram Widget, but offers more computability than the Diagram Document.

from IPython.display import display

If you just need to show a diagram (or want a really temporary scratchpad), just send a display message to the frontend with the application/x-drawio mimetype.

MIMETYPE = "application/x-drawio"


This mimetype is also available as ipydrawio.constants.MIMETYPE.

def display_drawio(xml, **kwargs):
    """Send some xml to the frontend

    Get a handle to update later by calling `display_drawio` with `display_id=True`
    return display({MIMETYPE: xml}, raw=True, **kwargs)

Apparently, an empty string is valid.

handle = display_drawio("")


The drawioUrlParams and drawioConfig (as well as width and height) can change how the application works.

handle = display_drawio(
        MIMETYPE: {"height": "200px", "drawioUrlParams": {"ui": "dark", "chrome": 0}},