wxdiagram
A zoomable shape-and-connector canvas for wxPython.
wxdiagram gives a wxPython application a modern diagram canvas without the
ceremony of wx.lib.ogl: shapes, edges, selection, zoom/pan, and JSON
persistence in a small MIT-licensed package.
It began life as ogl2, an internal canvas for
pynsource. The name is now retired; this
repository is the standalone library. See NOTICE.md for the wx.lib.ogl and
OGLlike attribution.
Features
- Canvas with real zoom/pan:
ZoomIn,ZoomOut,ZoomTo,ZoomReset,ZoomToFit,CenterOn; Ctrl+wheel and macOS pinch zoom anchored at the pointer; drag empty canvas to pan; mouse-wheel scrolling; virtual size tracks the diagram so panning cannot wander into empty space. - Selection and handles: shift-click multi-select, resize handles, hover ports, drag port-to-shape to connect.
- Connectors: attached lines whose endpoints are clipped to the shapes' perimeters, so edges always meet the facing sides and re-route when shapes move. Explicit lines support arrowheads (start/middle/end), splines, dashed pens, and bend control points.
- Shapes: rectangles, ellipses, polygons, points, lines, bitmaps, divided (UML-style) shapes, labelled blocks, composite shapes with layout constraints, and non-interactive text labels.
- JSON persistence:
Diagram.Save(path)/Diagram.Load(path)orwxdiagram.persistence; versioned, portable, no pickle. - Keyboard: Delete, Tab cycle, Ctrl+A, Ctrl+C/V.
- Headless-friendly: shapes and the diagram model work without showing a window.
Installation
Requires Python 3.10+ and wxPython 4.2+.
pip install wxdiagram
or from source with uv:
git clone https://github.com/abulka/wxdiagram.git
cd wxdiagram
uv sync
Quickstart
import wx
import wxdiagram
app = wx.App(redirect=False)
frame = wx.Frame(None, title="wxdiagram minimal", size=(600, 400))
canvas = wxdiagram.ShapeCanvas(frame)
canvas.SetDiagram(wxdiagram.Diagram())
shape = wxdiagram.RectangleShape(100, 100, 300, 200)
shape.AddText("hello world")
canvas.InsertShape(shape, 999)
frame.Show()
canvas.update_virtual_size()
app.MainLoop()
Connect two blocks with an attached line:
canvas.join_shapes(left_block, right_block)
The edge routes through the box perimeters, so it stays correct from any direction and follows the shapes when they move.
Demo and examples
uv run python -m wxdiagram.demo
The demo shows UML-style class boxes, a composite, a basic-shape gallery, a bitmap, a polyline and an arrowed line. It has Add, View and File menus, including JSON save/load.
Small runnable scripts live in examples/:
minimal_canvas.py— the 30-line hello worldconnect_two_blocks.py— attached-line connectionszoom_to_fit.py— zoom and pansave_load.py— save and load with JSON
Scope
wxdiagram is a canvas library, not a UML framework or a full layout
engine. It deliberately does not include:
- a UML parser or graph model
- application menus, licensing, or PlantUML integration
- a Sugiyama/A* layout engine
- complete
wx.lib.oglAPI parity
Layout is pluggable; an application can run its own layout and hand positions
to the canvas. See docs/migration-from-wx-lib-ogl.md for a detailed
comparison with wx.lib.ogl.
Status
Beta (0.1.0). The public API is still settling, so pin a version if you
depend on it. pynsource is the main downstream consumer.
License
MIT, see LICENSE.md. The wx.lib.ogl and OGLlike attribution is in
NOTICE.md.
Metadata
Release files for wxdiagram 0.1.0
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 |
|---|---|---|---|---|
| wxdiagram-0.1.0.tar.gz | 73.6 kB | With provenance | Details for wxdiagram-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| wxdiagram-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for wxdiagram-0.1.0-py3-none-any.whl |
Total release size: 141.2 kB
Release files / wxdiagram-0.1.0.tar.gz
| Download URL | wxdiagram-0.1.0.tar.gz |
|---|---|
| Size | 73.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5faf975ec09cc6872d7d109625bada48100e7f097ce8f38c2cdea00456effb8f
|
|
BLAKE2b-256 checksum How to use checksums |
4eb70592ad59aaf8c67352c11c82270edd34702f6d644127917b1f36950ab582
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logRelease files / wxdiagram-0.1.0-py3-none-any.whl
| Download URL | wxdiagram-0.1.0-py3-none-any.whl |
|---|---|
| Size | 67.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
060243d4419585a012dd2b17a03a3520f35f8b497d3ed8d0190c40a029796dfa
|
|
BLAKE2b-256 checksum How to use checksums |
7497f0148c9ca87e1865fd8db471cea922dd539703e6e7c26db5dd224a5bf480
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logSecurity for wxdiagram 0.1.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for wxdiagram-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.
Transparency logA 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.