svg.py

SVG drawing library

MIT 16 个版本 Python >=3.7
Gram <gram@orsinium.dev>
安装
pip install svg.py
poetry add svg.py
pipenv install svg.py
conda install svg.py
描述

svg.py

Python library to generate SVG files.

Features:

  • Compatible with all SVG standards: 1.1, 1.2, 2.0, Tiny.
  • 100% type safe.
  • Pure Python.
  • No third-party runtime dependencies.
  • No deprecated attributes, only what actually works.
  • The same names and structure as in the standard. If you know how to write SVG files, you know how to use this library.

Based on svg-xsd-schema and MDN reference.

Installation

python3 -m pip install --user svg.py

Usage

Try svg.py online: svg.orsinium.dev.

import svg
canvas = svg.SVG(
    width=60,
    height=60,
    elements=[
        svg.Circle(
            cx=30, cy=30, r=20,
            stroke="red",
            fill="white",
            stroke_width=5,
        ),
    ],
)
print(canvas)

See examples for more.

Projects using svg.py

The github topic svg-py contains some of the projects that use svg.py in one way or another. If you want your project to appear on the list, simply add svg-py into the list of project topics. Here is how.

版本列表
1.10.0 2025-12-28
1.9.2 2025-10-18
1.9.1 2025-10-03
1.9.0 2025-09-30
1.8.0 2025-08-11
1.7.0 2025-07-04
1.6.0 2025-03-16
1.5.0 2024-09-23
1.4.3 2024-02-20
1.4.2 2023-04-25
1.4.1 2022-11-22
1.4.0 2022-09-22
1.3.0 2022-08-08
1.2.0 2022-06-30
1.1.0 2022-06-11
1.0.0 2021-10-25