QAnsiTextViewer
ANSI Text Viewer - QT Widget
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.
Release files for qansitextviewer 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| qansitextviewer-0.1.1.tar.gz | 2.7 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| qansitextviewer-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:2.7 MB
Release files / qansitextviewer-0.1.1.tar.gz
| Download URL | qansitextviewer-0.1.1.tar.gz |
|---|---|
| Size | 2.7 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f50a833bc150485619120c936bb6d4397d17a3ee5b9480d68dbf179d96653c50
|
|
BLAKE2b-256 checksum How to use checksums |
cbcc9ac8b39cdb3c8935f751364c7d1b2ad4b0fced3cbe2d205b0a73e33944b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","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.1-py3-none-any.whl
| Download URL | qansitextviewer-0.1.1-py3-none-any.whl |
|---|---|
| Size | 33.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc7439072ec18087d9022a3f733a22cbbe1e545a2122421a581d6a8bb697c141
|
|
BLAKE2b-256 checksum How to use checksums |
f0fbe620960bcf64a6118befa67b94703ec2ef62d7b2fab5d58f180fae9fed1b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","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}
|