Excalidraw_Interface
A pythonic interface for creating diagrams in Excalidraw.
Based on https://github.com/BardOfCodes/procXD by Aditya Ganeshan (MIT License) and updated with modern python support and API improvements.
Example: Flowchart
from Excalidraw_Interface import SketchBuilder
flowchart_items = ['First Step', 'Second Step', 'Third Step']
sb = SketchBuilder() # Create a Sketch
prev_item = sb.TextBox("Start Here", x = 0, y = 0) # Create a Text Box
for index, item in enumerate(flowchart_items):
new_item = sb.TextBox(item, x = 0, y = (index+1) * 150) # Create a Text Box
sb.create_binding_arrows(prev_item, new_item) # Create arrows between boxes
prev_item = new_item
hcb = sb.HeaderContentBox("Header", "Content", x = -200, y = 400) # Create a multiline text box
circle = sb.Ellipse(200, 400, width=50, height=50, backgroundColor = 'red',
roughness=1) # Create a red circle in hand drawn style
sb.create_binding_arrows(prev_item, hcb, sb.DoubleArrow) # Create a double headed arrow
sb.create_binding_arrows(prev_item, circle, strokeColor = 'blue') # Create an blue arrow
sb.export_to_file('out.excalidraw')
Documenation
SketchBuilder
Every sketch starts by creating a sketch builder object.
from Excalidraw_Interface import SketchBuilder
sb = SketchBuilder() # Create a Sketch
Default settings for the sketch can be set using kwargs. For instance:
from Excalidraw_Interface import SketchBuilder
sb = SketchBuilder(roughness=2) # Create a hand drawn sketch
The list of configurable settings can be found in defaults.py
Exporting a Sketch
from Excalidraw_Interface import SketchBuilder
sb = SketchBuilder()
...
sb.export_to_file('my_sketch')
# OR
data = sb.export_to_json()
Creating Sketch Objects
Rectangles, Diamonds, Ellipses can be created with a center_x and center_y position. Width and height can also be set (defaults to 100). Other params can be set in kwargs.
from Excalidraw_Interface import SketchBuilder
sb = SketchBuilder()
sb.Rectangle(x = 0, y = 0)
sb.Diamond(x = 0, y = 0, width=50, height=20)
sb.Ellipse(x = 0, y = 0, backgroundColor='red')
Text, Lines, and Arrows have similar functions.
from Excalidraw_Interface import SketchBuilder
sb = SketchBuilder()
sb.Text('some text', x = 0, y = 0)
sb.Line((0,0), (100,100))
sb.Arrow((0,0), (100,100))
sb.DoubleArrow((0,0), (100,100))
TextBoxes and HeaderContentBoxes have special functions to create multiple objects at once.
Config can be passed to txt_kwargs, rect_kwargs, header_kwargs, or content_kwargs.
from Excalidraw_Interface import SketchBuilder
sb = SketchBuilder()
sb.TextBox('some text', x = 0, y = 0)
sb.HeaderContentBox('TITLE', 'content', x = 0, y = 0)
Advanced Sketch Objects
To create arrows between two objects:
from Excalidraw_Interface import SketchBuilder
sb = SketchBuilder()
a = sb.TextBox('some text', x = 0, y = 0)
b = sb.TextBox('some text', x = 200, y = 200)
sb.create_binding_arrows(a, b)
sb.create_binding_arrows(a, b, sb.DoubleArrow, strokeColor='blue') #makes a blue double arrow
To create shape around an object (or Group):
from Excalidraw_Interface import SketchBuilder
sb = SketchBuilder()
a = sb.TextBox('some text', x = 0, y = 0)
outer_rect = sb.create_bounding_element(a)
To create groups:
from Excalidraw_Interface import SketchBuilder, Group
sb = SketchBuilder()
a = sb.TextBox('some text', x = 0, y = 0)
b = sb.TextBox('some text', x = 200, y = 200)
g = Group([a, b])
For more examples see advanced_groups.py
Notes:
Groups can be nested.
A special feature exists that allows one element of a group to be treated as the whole group for the purpose of further grouping (useful for bounding boxes).
if first_is_group:
elems[0].apply_recursive_groups.extend(elems[1:])
Metadata
Release files for Excalidraw-Interface 0.1.3
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 | |
|---|---|---|---|---|
| excalidraw_interface-0.1.3.tar.gz | 398.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| excalidraw_interface-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 797.1 kB
Release files / excalidraw_interface-0.1.3.tar.gz
| Download URL | excalidraw_interface-0.1.3.tar.gz |
|---|---|
| Size | 398.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
20232dbf2d597d718109d67519bc23e2fd7bf65383b41af4f6d193a57574b510
|
|
BLAKE2b-256 checksum How to use checksums |
3db45bc46c249d29866735b8ec86a253bcf27f4b441b37efbf8d086eb025a61f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / excalidraw_interface-0.1.3-py3-none-any.whl
| Download URL | excalidraw_interface-0.1.3-py3-none-any.whl |
|---|---|
| Size | 398.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
370e7394590e6d3c8ca87d5daf1c0b4f8e68bcd838c54603450afa41f4fe2d8b
|
|
BLAKE2b-256 checksum How to use checksums |
9ed33d47a0556f028506a98950768e36ab1c92a514f4738b48407ad1a6886565
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Security for Excalidraw-Interface 0.1.3
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.