Skip to content

koaning/modraw

Repository files navigation

modraw

"A collection of tldraw based anywidgets for marimo, but also other Python notebooks."

The project uses anywidget under the hood so our tools should work in Marimo but also Jupyter, Shiny for Python, VSCode, Colab, Solara and Marimo. Because of the anywidget integration you should also be able interact with ipywidgets natively.

Online demos

Check Github pages for a live demo.

Installation

Installation occurs via pip or uv.

python -m pip install modraw
uv pip install modraw

Usage

Draw

The main widget that's available in this library is the Draw widget. This generates a ltdraw widget and you're able to retreive the drawn image in a base64 representation or as a Python image object.

import marimo as mo
from modraw import Draw

widget = mo.ui.anywidget(Draw())
widget
# Fetch the doodle and put it in Python
widget.get_base64()
widget.get_pil()

Related project

This isn't the only tldraw integration with Python, you might also be interested in jupyter-tldraw. It's a neat project for sure, and the main difference is that this project tries to target marimo more directly and can also move a bit faster with that in mind. I'm currently employed at marimo, so having a tool that I can easily change is very useful.

Development

I am currently exploring how we might move some of these components to react, mainly in an attempt to keep things flexible in the future. There's no need to port everything just yet but I have ported the clipboard button. You should be able to develop it via:

make install
make dev

About

Drawing utils from tldraw for marimo

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published