Skip to main content

QAnsiTextViewer

CI Docs PyPI CodeQL OpenSSF Scorecard

ANSI Text Viewer - Qt log-viewer widget for Python

Drop-in QWidget that renders ANSI escape codes and colored terminal output: tail logs, search and filter them, bookmark lines, and save sessions. Works with both PySide6 (tested) and PyQt (same Qt API, no code changes).

Install

uv add qansitextviewer
# or from GitHub / local build:
uv add git+https://github.com/tanishq-kumar/QAnsiTextViewer
uv build && uv pip install dist/qansitextviewer-*.whl
# or clone + develop:
uv sync --group dev

Requires Python >=3.11, PySide6 >=6.5.0.

Quick start

from PySide6.QtWidgets import QApplication
from ansi_text_viewer import AnsiTextViewer

app = QApplication([])
viewer = AnsiTextViewer()
viewer.appendAnsiText("\x1b[31mred\x1b[0m plain\n")
viewer.highlight_search("red")  # F3 / Shift+F3 navigates, Esc clears
viewer.setTheme("dark")
viewer.show()
app.exec()

Full demo app: just demo (or uv run python demo.py).

API cheatsheet

Task Call
Append / replace appendAnsiText(s), setAnsiText(s) (\r = progress overwrite)
Non-blocking burst appendAnsiTextAsync(s) + asyncAppendProgress / asyncAppendFinished, cancelAsyncAppends()
Search / filter highlight_search(q, use_regex, match_case), next_match(), prev_match(), filter_search(q, ...)
Limits setMaximumBlocks(10000), setMaxLineLength(10000) (0 = off)
Look setTheme("light"|"dark"|"auto"), setMonospaceFont(), setFontSize(), setFontFamily(), useSystemFont(), setWordWrapEnabled(), setCurrentLineHighlightEnabled()
Appearance Theme-following defaults; setDefaultColors(fg, bg), setColorsFollowTheme(bool), setAnsiPaletteColor(), setLogLevelColors(), setBookmarkColor(), setSearchHighlightColor()
Log helpers setTimestampEnabled(), setLogLevelHighlighting(), setSyntaxHighlighting()
Custom highlight add_highlight_rule(rule) with spans(text) (ansi_text_viewer.highlight)
Bookmarks toggleBookmark() (or gutter click), gotoNextBookmark(), bookmarkedLines(), bookmarksChanged signal
Copy / export copySelectedPlainText(), copySelectedWithAnsi(), exportToFile(path) (.txt/.html/.md)
Sessions saveSession("s.json"), loadSession("s.json")
Shortcuts Ctrl+F → findRequested, F3/Shift+F3, Esc (app-wide)

Dev Commands

just test · just demo · just run · just lint · just typecheck · just docs-build — see justfile.

FAQ

PySide6 or PyQt?

PySide6 is the tested dependency. PyQt exposes the same QWidget API, so the viewer works there too — report any gap as a bug.

Why not QPlainTextEdit + manual parsing?

That's exactly the boilerplate this widget removes: SGR/256-color/truecolor parsing, \r progress lines, search, bookmarks, themes, and session save/load in one typed widget.

How is this different from a terminal emulator?

Terminal emulators run interactive shells. This is a read-oriented log viewer: append-only text, regex search/filter, bookmarks, and export to .txt/.html/.md.

Metadata

Release files for qansitextviewer 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qansitextviewer 0.1.2
File Size Uploaded
qansitextviewer-0.1.2.tar.gz 66.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for qansitextviewer 0.1.2
File Interpreter ABI Platform
qansitextviewer-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 100.3 kB

Release files / qansitextviewer-0.1.2.tar.gz

Download URL qansitextviewer-0.1.2.tar.gz
Size 66.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2bfae7adda14ab166af66b2ab53bfbb1d4a4807b479df6a5aa981cc1bda6dfb5
BLAKE2b-256 checksum
How to use checksums
effb3c5f9af7a4c046d4dc928ff5c3a7cff2e79d9b510b4eb173e1f430aa4205
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / qansitextviewer-0.1.2-py3-none-any.whl

Download URL qansitextviewer-0.1.2-py3-none-any.whl
Size 33.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
259a253f041f4c8e4d20f64a71d1dea63c46a20db0e1f023bb3bfb46ba8190cc
BLAKE2b-256 checksum
How to use checksums
fb513aac51b7e85668cd47b2e9495bd251d9311978890a70289a9836d2409142
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page