Drawpyo is a Python library for programmatically generating Diagrams.net/Draw.io charts. It enables creating a diagram object, placing and styling objects, then writing the object to a file.
History/Justification
I love Draw.io! Compared to expensive and heavy commercial options like Visio and Miro, Draw.io's free and lightweight app allows wider and more universal distribution of diagrams. Because the files are stored in plaintext they can be versioned alongside code in a repository as documentation. The XML-based file format makes these diagrams semi-portable, and could easily be ported to other applications if Draw.io ever failed you. For these reason, I think it's one of the best options for documentation diagrams.
When I had a need to generate heirarchical tree diagrams of requirement structures I was surprised to find there wasn't even a single existing Python library for working with these files. I took the project home and spent a weekend building the initial functionality. I've been adding functionality, robustness, and documentation intermittently since.
Full Documentation
Available here!
https://merrimanind.github.io/drawpyo/
Basic Usage
The basic mode of interacting with drawpyo is to manually create, style, and place objects just like you would using the Draw.io UI. There are a number of ways to style objects and you can write your own functionality for automatically handling style or placement.
Make a new file
import drawpyo
file = drawpyo.File()
file.file_path = r"C:\drawpyo"
file.file_name = "Test Generated Edges.drawio"
# Add a page
page = drawpyo.Page(file=file)
Add an object
item = drawpyo.diagram.Object(page=page, value="new object")
item.position = (0, 0)
Create an object from the base style libraries available in the Draw.io UI
item_from_lib = drawpyo.diagram.object_from_library(
page=page,
library="general",
obj_name="process",
value="New Process",
)
Style an object from a string
item_from_stylestr = drawpyo.diagram.Object(page=page)
item_from_stylestr.apply_style_string("rounded=1;whiteSpace=wrap;html=1;fillColor=#6a00ff;fontColor=#ffffff;strokeColor=#000000;gradientColor=#FF33FF;strokeWidth=4;")
Write the file
file.write()
Usage with Diagram Types
Drawpyo also provides higher-level functionality that goes beyond what the Draw.io app offers. These diagram types allow you to generate complete structures automatically, without manually placing every element.
This video demonstrates an exemplary automatic diagram layout process:
For more details, refer to the documentation.
Contributions
Contributions are welcome. See the contribution guidelines or join our Discord server for more information.
Metadata
Release files for drawpyo 0.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| drawpyo-0.2.5.tar.gz | 49.7 kB | Without provenance | Details for drawpyo-0.2.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| drawpyo-0.2.5-py3-none-any.whl | Python 3 | none | any | Details for drawpyo-0.2.5-py3-none-any.whl |
Total release size: 108.9 kB
Release files / drawpyo-0.2.5.tar.gz
| Download URL | drawpyo-0.2.5.tar.gz |
|---|---|
| Size | 49.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
28087c5b7975335f88aa5ee289b29b10d634acc1415ae7816bd3629a193f6a8e
|
|
BLAKE2b-256 checksum How to use checksums |
f770a5308052c167fb718fb0b67b608fdda3ebff8516a8d2c6f1541dd963a475
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / drawpyo-0.2.5-py3-none-any.whl
| Download URL | drawpyo-0.2.5-py3-none-any.whl |
|---|---|
| Size | 59.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9cab60ecf75963e83c144f8bb440d075f6c7887f9d6e735b8bd44d67d37274a3
|
|
BLAKE2b-256 checksum How to use checksums |
977c8027e842f290d074163b2b6356a432521c86217f56a3dcc1d41fe7bf9af3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for drawpyo 0.2.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.