Skip to main content

Automatically generate node icons for Python Diagrams based on label text

Project description

Autonode Diagrams

The Python Diagrams project is an excellent resource for drawing technical diagrams using code, allowing diagrams to be version controlled easily and you to spend time writing content rather than fussing over formatting.

However, one current limitation is that all nodes of the diagram must have both a label and an icon to be displayed. Although Diagrams comes with a large number of relevant node types and corresponding icons pre-installed, and the custom node allows you to extend this even further, sometimes you don't have a suitable icon for the node available, or you want to quickly generate a diagram and worry about populating the icons later.

This package extends the Diagram's Custom Node and automatically generates an icon based on the text in the node's label if no icon is provided. It is designed to be used in conjunction with, not as a replacement to, Diagrams.

Demonstration

Quick Start

Most of this code is taken from the Diagram's Quick Start guide plus Custom nodes with remote icons guide. This is to show how Autonode Diagram's Icon class integrates seamlessly with the rest of the regular Python Diagram's functionality, allowing the two to be used side-by-side.

from diagrams import Diagram
from diagrams.programming.language import Python
from diagrams.custom import Custom
from autonode_diagrams import Icon
from urllib.request import urlretrieve

with Diagram("Quick Start", show=False):
    # Get a remote PNG to prove that autonode_diagrams.Icon can also work just like normal diagrams.custom.Custom
    emoji_url = "https://openmoji.org/php/download_asset.php?type=emoji&emoji_hexcode=2728&emoji_variant=color"
    emoji_fp = "./sparkle.png"
    urlretrieve(emoji_url, emoji_fp) # You can delete this file later
    
    Icon("Just a label, no icon given", border=True) >> Python("Autonode Diagrams") >> Icon("Something beautiful", emoji_fp)

Prerequisites

  • Arial font.
  • Python Diagrams along with their dependencies (specifically Graphviz will need to be installed).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autonode_diagrams-1.0.4.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

autonode_diagrams-1.0.4-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file autonode_diagrams-1.0.4.tar.gz.

File metadata

  • Download URL: autonode_diagrams-1.0.4.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.10.2 Darwin/22.5.0

File hashes

Hashes for autonode_diagrams-1.0.4.tar.gz
Algorithm Hash digest
SHA256 87d63fb92dd171ec1c70b552f0a9eb7b3e5fcce937610de3ee3d76d99daf8994
MD5 3badd541b768f6220a5c3c90a05fce83
BLAKE2b-256 665eb97ffab59e500fb08c7419b19d991b6b5bd4fec13ab9954a66c5df83a571

See more details on using hashes here.

File details

Details for the file autonode_diagrams-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for autonode_diagrams-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 42a994748107a2ea54fbe96a50a3afb6bb45a21c04c9a5956380d0494a02c825
MD5 3cc5f491ea63bc759c53d23552941d95
BLAKE2b-256 0b3d6a7505bf206e8103048cd5e8482635bc9b4d97bb376bc6423b64c01122c5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page