Registry / web-framework / pictex

pictex

JSON →
library2.3.0pypypi✓ verified 91d ago

PicTex is a Python library for generating images via CSS Flexbox layout. It uses a declarative API to compose elements, supports text shaping via HarfBuzz, Unicode bidirectional text, gradients, and inline spans. Current version 2.3.0 requires Python >=3.9. Releases occur irregularly, with breaking changes in v2.0.0 that renamed many methods.

pip install pictex
INSTALL
IMPORT
SIG · PICTEX
P
pictex
web-frameworkpythonv2.3.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Canvas
✓ from pictex import Canvas
✗ from pictex.canvas import Canvas
Canvas is a top-level export; no submodule needed.
Span
✓ from pictex import Span
✗ from pictex.text import Span
Span is exported from the main package.
RadialGradient
✓ from pictex import RadialGradient
✗ from pictex.gradients import RadialGradient
Gradient classes are top-level exports.

Creates a 200x100 canvas with a blue rectangle and text, renders to PNG.

from pictex import Canvas, Text, Rect canvas = Canvas(200, 100, background_color="white") canvas.add(Rect(width=50, height=50, background_color="blue")) canvas.add(Text("Hello, PicTex!")) image = canvas.render() image.save("output.png")
Debug
Known issues
breakingv2.0.0 introduced breaking changes: many methods were renamed to match CSS terminology (e.g., add_static was removed, layout changed). Existing code from v1.x will not work without migration.
fix
Follow the migration guide at https://github.com/francozanardi/pictex/blob/main/docs/MIGRATION.md
affects: <2.0.0
deprecatedThe v2.0.0 release replaced Skia with HarfBuzz for text shaping. If you were using skia-specific features or relying on Skia fonts, you may need to adjust.
fix
Use standard font paths; HarfBuzz handles shaping automatically.
affects: >=2.0.0
gotchaText wrapping can behave unexpectedly when no width constraint is set. Floating-point precision may cause false word-wrapping. In v2.1.1 this was fixed, but it's still a good practice to set a width for text elements.
fix
Always specify a width on text-containing elements, e.g., Text("...", width=200).
affects: >=2.1.0
gotchaInline spans (Span) are new in v2.3.0. They are deeply nestable but properties cascade; forgetting to override a property may lead to unintended inheritance. The note says 'properties cascade down and inherit naturally unless explicitly overridden'.
fix
Explicitly set properties on each Span to avoid inheritance surprises.
affects: >=2.3.0
Errors
Common errors & fixes
ImportError: cannot import name 'Canvas' from 'pictex'
Installed version is too old (<2.0.0) or PicTex not installed correctly.
fix
Upgrade to latest: pip install --upgrade pictex
ModuleNotFoundError: No module named 'pictex'
PicTex is not installed.
fix
Install: pip install pictex
AttributeError: 'Canvas' object has no attribute 'add_static'
Method renamed in v2.0.0 breakage.
fix
Use canvas.add() or the new positioning methods. See migration guide.
Upgrade
Version history
2.3.0latest on PyPI · released Apr 3, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
Anthropic
1
Resources
pictex — pip install pictex · libregistry