WaveDrom Python Library

2.0.3.post3 · active · verified Fri Apr 17

The `wavedrom` Python library provides a command-line utility and programmatic API for generating digital waveform diagrams from WaveJSON/WaveJSON5 input. It's compatible with the WaveDrom JavaScript library specification, allowing users to define waveform signals in a simple JSON format and render them into SVG images. The current version is 2.0.3.post3, with active maintenance and occasional releases addressing bugs and minor features.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to programmatically render a WaveJSON string into an SVG image using the `render_wavedrom_svg` function. The input is a multi-line string containing the WaveJSON specification.

import json
from wavedrom.render import render_wavedrom_svg

# Define your WaveJSON/WaveJSON5 data as a string
wavejson_data = '''
{
  "signal": [
    { "name": "clk", "wave": "p.....|..." },
    { "name": "d",   "wave": "x.345x|x.23" },
    { "name": "q",   "wave": "10101x|1010" }
  ],
  "head": { "text": "My Simple Waveform" }
}
'''

# Render the WaveJSON string to an SVG string
svg_output = render_wavedrom_svg(wavejson_data)

# You can now save the SVG string to a file or embed it
# with open("waveform.svg", "w") as f:
#     f.write(svg_output)

# print(svg_output[:200]) # Print start of SVG to confirm

view raw JSON →