QAnsiTextViewer¶
A drop-in Qt widget for Python that renders ANSI-colored terminal output, so you can tail logs, search them, bookmark lines, and save sessions.

\r progress line that finished in place, and clickable paths and URLs.Quick start¶


Install¶
Requires Python >=3.11 and PySide6 >=6.5.0.
Next¶
- Your first log pane Put the viewer in a window with a search box, match counter, and filter.
- Streaming process output Tail a subprocess, dump huge logs without freezing, pause and resume.
- Themes and colors Light, dark, OS-following auto, plus custom ANSI palettes.
- API reference Every viewer method, signal, and shortcut; highlight rules and internals sit beside it under Reference.
What it does¶
| Feature | In short |
|---|---|
| One widget | A typed QWidget; every behavior has a setter/getter pair. |
| ANSI parsing | SGR, 256-color, and truecolor sequences; \r progress lines overwrite in place. |
| PySide6 and PyQt | Built on PySide6, and compatible with PyQt through the same Qt API. |
| Search & filter | Highlight with regex, jump with F3, hide non-matching lines. |
| Bookmarks | Gutter click, list panel, next/previous navigation, saved in sessions. |
| Themes | Light, dark, OS-following auto, plus custom ANSI palettes. |
| Non-blocking | Chunked async appends keep the UI alive through 100k-line bursts. |
Try the demo
In a clone of the repository, just demo (or uv run python demo.py)
launches the full showcase: streaming logs, progress bars, bookmarks,
sessions, themes, and palette pickers. Prefer pictures?
Take the visual tour — every feature annotated.
Untrusted logs
Log content is untrusted by design. Links open only on Ctrl + click,
cursor jumps are clamped, and huge lines are truncated. For hostile
logs, call viewer.setLinksEnabled(False).
Why QAnsiTextViewer?¶
QPlainTextEdit+ hand-rolled parsing — the default DIY route. You end up re-implementing SGR tables,\rhandling, search, and themes. This widget is that work, finished and tested.- Terminal emulator widgets (e.g. QTermWidget-based) — built for interactive shells, heavy to embed, and poor at search/bookmarks/export. This is a read-oriented log viewer instead.
- Web views — rendering logs as HTML in
QWebEngineViewworks but drags in a browser engine for colored text. Native Qt stays light.
FAQ¶
Does it work with PyQt?
PySide6 is the tested dependency, but the widget only uses the shared Qt
QWidget API, so PyQt6/PyQt5 work with no code changes. Report gaps as bugs.
Can I use it outside Python?
No — it is a Python class (via Qt for Python) and cannot be imported from C++, Rust, or other languages. The ANSI parser module is deliberately kept free of widget imports so a future port only re-implements that core.
How large can logs get?
setMaximumBlocks() caps memory (oldest blocks are discarded) and
setMaxLineLength() truncates hostile lines. The performance notes in
Internals cover the 100k-line burst path.