71686e8ad4d911fd902b55e330f01dfb0a6641b6
CI / test (push) Failing after 6m11s
- receipt_tui.py: Textual terminal UI (tui subcommand), optional [tui] extra - tests/: pytest suite for CLI and TUI using fakes; no hardware needed - pyproject.toml: packaging with dev/tui extras, ruff config - GitHub Actions CI running ruff and pytest - Rename connect_recipt.sh -> connect_receipt.sh - CLAUDE.md project instructions; README updates Co-Authored-By: Claude Fable 5 <[email protected]>
Receipt Maker
Prints images, text notes, and QR codes to an Epson TM-T20II thermal receipt printer, including random images from 4chan's /bant/ board.
How it works
connect_receipt.sh— brings up the USB Ethernet interface, assigns192.168.192.10/24, and waits until the printer at192.168.192.168:9100is reachablereceipt.py— CLI with subcommands; images are resized in memory to the printer's full 576px width before printing
The CLI runs the connect script automatically before printing (unless --usb is used).
Requirements
- Python 3.10+
python-escpos,Pillow,requests(seepyproject.toml)textual(optional, only for thetuisubcommand;pip install '.[tui]')- Epson TM-T20II connected via a USB-to-Ethernet adapter (or directly over USB with
--usb)
Install the dependencies (or pip install . to also get a receipt command on your PATH):
pip install python-escpos Pillow requests
Usage
# Print a random image from /bant/ (optionally more than one)
./receipt.py image
./receipt.py image 3
# Print a text note (from an argument or stdin), word-wrapped to 48 columns
./receipt.py note "your message here"
fortune | ./receipt.py note
./receipt.py note -t "with a date/time header"
# Print a local image (with optional caption)
./receipt.py print path/to/image.jpg
./receipt.py print path/to/image.jpg "optional caption"
# Print a QR code (with optional caption)
./receipt.py qr "https://example.com" "scan me"
# Reprint a cached image (most recent, or by name from `list`)
./receipt.py reprint
./receipt.py reprint 1783716801701399
# Check the printer is reachable
./receipt.py status
# List or delete the downloaded image cache
./receipt.py list
./receipt.py clean
# Open the interactive terminal UI (needs `pip install textual`)
./receipt.py tui
# Use a direct USB connection instead of Ethernet
./receipt.py --usb note "hello"
# Point at a different printer (or set RECEIPT_PRINTER_IP / RECEIPT_PRINTER_PORT)
./receipt.py --ip 10.0.0.5 --port 9100 status
Images are prepared for thermal output automatically: transparency is composited onto white, then the image is resized to full width, autocontrast-stretched, and Floyd-Steinberg dithered.
Development
pip install -e '.[dev]'
pytest # run the tests
ruff check . # lint
Both checks also run in CI on every push and pull request (.github/workflows/ci.yml).
Files
receipt.py— main scriptreceipt_tui.py— Textual terminal UI (./receipt.py tui)connect_receipt.sh— network setup for the USB Ethernet adaptertests/— pytest suite for the CLI and TUI (no printer or network needed)img/— downloaded images cache (gitignored; clear with./receipt.py clean)
Languages
Python
69.3%
JavaScript
24.4%
CSS
4.8%
Shell
1.3%
HTML
0.2%