Metadata-Version: 2.4
Name: qltool
Version: 0.2.6
Summary: PRINT simple labels on ql700
Requires-Python: >=3.10
Requires-Dist: click>=8.2.1
Requires-Dist: console>=0.9911
Requires-Dist: importlib-resources>=6.5.2
Requires-Dist: opencv-python>=4.12.0.88
Requires-Dist: paho-mqtt>=2.1.0
Requires-Dist: pillow>=11.3.0
Requires-Dist: qrcode>=8.2
Description-Content-Type: text/markdown

# qltool 0.2.4

*Tool to print labels with Brother QL-700/QL-570 label printer*

A wrapper around the excellent `ql570.c` by Asbjørn Sloth Tønnesen, Marc Juul and Luca Zimmermann.

## Features

- Print text labels (1-3 lines)
- Print QR codes with text
- Print banners (text along paper length)
- Custom font sizes
- MQTT client for remote printing
- Preview before printing

## Installation

Using `uv` (recommended):

```bash
uv pip install -e .
```

Or with pip:

```bash
pip3 install qltool
```

## Usage

### Standard Label Print

Print 1-3 lines of text:

```bash
# Preview only
uv run src/qltool/main.py "Line 1" "Line 2" "Line 3" --font-size 40

# Print with specific font size
uv run src/qltool/main.py "Hello World" "Second line" -p --font-size 55
```

### QR Code Labels

```bash
# Generate and print QR code with text
uv run src/qltool/main.py "Item: 12345" "Location: Office" -q -p

# Use existing QR image
uv run src/qltool/main.py "Scan me" --qr /path/to/qrcode.png -p
```

### Banner Mode (Text along paper length)

```bash
# Preview banner
uv run src/qltool/main.py "Long text banner" --banner --font-size 40

# Print banner
uv run src/qltool/main.py "STS Chvojkovice-Brod" --banner --font-size 40 -p
```

### Command Options

- `-p, --print` - Send to printer (without this, shows preview)
- `-q, --qr` - Generate QR code
- `--qr PATH` - Use existing QR image
- `--banner` - Create banner (text along paper length)
- `--font-size N` - Set font size (default: 72)
- `--width N` - Set image width in pixels (default: 714 for 62mm tape)
- `--gray N` - Gray bias 0-100 (default: 50)
- `-d, --device` - Specify printer device (default: auto-detect /dev/usb/lp*)

## MQTT Client

Run the MQTT client for remote printing:

```bash
qltool_client
```

Send print jobs via MQTT:

```bash
# Simple print
mosquitto_pub -t qltool/print -m "Hello World -p"

# With QR code
mosquitto_pub -t qltool/print -m "Inventory Item -q -p"

# Banner
mosquitto_pub -t qltool/print -m "Long banner text --banner -p"
```

## Development

Run directly from source:

```bash
# Preview
uv run src/qltool/main.py "Test text" --font-size 40

# Print
uv run src/qltool/main.py "Test text" --font-size 40 -p
```

## Requirements

- Brother QL-700 or QL-570 printer
- User must be in `lp` group for printer access
- Linux with USB lp device support (`/dev/usb/lp*`)

## Org-mode Integration (Inventory)

For Emacs org-mode table integration:

```elisp
;; Add to .emacs
(defun print-inventory-item ()
  "Print current org table row as label"
  (interactive)
  ;; Your implementation here
  )
```

Example table format:

| ID          | Name                        | Owner | Location |
|-------------|-----------------------------|-------|----------|
| D4-12345678 | Sample inventory item       | Pepa  | Home     |

The tool can extract ID and name fields to generate QR-coded inventory labels.

## Credits

- `ql570.c` driver by Asbjørn Sloth Tønnesen, Marc Juul and Luca Zimmermann
- Built with Python, Click, Pillow, and OpenCV
