README auf Englisch und Deutsch, Konfiguration und Sicherheit ergänzt

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Michael RollandClaude Opus 5.5 committed 2026-11-24 12:18:49 +01:00
1 parent 2abedb1dbc
commit efc3cc26ea
3 files changed
+307 -165

No files matched your search

+51 -165
View File
@@ -1,185 +1,71 @@
# P-Touch Web fuer Brother PT-P700
# P-Touch Web for Brother PT-P700
Kleine Flask-Weboberflaeche zum Erstellen von Etiketten und Drucken auf einem Brother P-Touch P700, der per USB an einem Unraid-Host haengt.
**English** | [Deutsch](README.de.md)
Die Weboberflaeche bildet die wichtigsten P-touch-Editor-Funktionen nach:
A small Flask web app to design labels and print them on a Brother P-touch
PT-P700 connected by USB to a Docker host (e.g. Unraid). It recreates the most
important P-touch Editor functions in the browser.
- Bandbreite, automatische Laenge, Rand und Ausrichtung
- frei positionierbare Objekte auf einem Etiketten-Canvas
- Textfelder, Symbole, Rahmen/Formen, Linien und Tabellen
- Bildimport mit Schwarz/Weiss-Konvertierung
- QR-Code und Code128-Barcode
- Layout speichern/laden im Browser
- serverseitige Vorschau und Druck ueber `ptouch-print`
- Band-Erkennung mit Breite, bedruckbarer Pixelbreite, Bandtyp, Hintergrundfarbe und Schriftfarbe
- einfache Text-only Mobile-Webansicht unter `/mobile`
- Schnittmodi: normal, Kettendruck/Streifen, Schnittmarke und Streifen mit Schnittmarke
## Features
## Wichtig fuer den PT-P700
- Tape width, automatic length, margin and orientation; tape detection (width,
printable pixels, tape type, colours)
- Freely positioned objects: text, symbols, frames/shapes, lines, tables
- Image import with black/white conversion, QR code and Code128 barcode
- Save/load layouts in the browser, server-side preview
- Cut modes: normal, chain print/strip, cut mark, strip with cut mark
- Print queue that waits until the printer is reachable
- Simple text-only mobile view at `/mobile`
Der PT-P700 muss im normalen Druckermodus laufen, nicht im "Editor Lite" Massenspeicher-Modus. Falls er im Host als USB-Laufwerk erscheint, Editor Lite am Geraet deaktivieren bzw. das Laufwerk auswerfen und den Drucker neu verbinden.
## Requirements
Wenn `lsusb` so etwas zeigt, ist der Drucker noch im falschen Modus:
- Brother PT-P700 in **normal printer mode** (Editor Lite LED off; it must not
show up as `RemovableDisk` in `lsusb`)
- Docker with USB access to the printer: `/dev/bus/usb` mounted and a privileged container
- Printing uses [`ptouch-print`](https://github.com/farixembedded/ptouch-print),
which is built into the image
```text
Brother Industries, Ltd PT-P700 P-touch Label Printer RemovableDisk
```
## Installation
Dann am PT-P700 die `Editor Lite`-Taste druecken, bis die Editor-Lite-LED aus ist. Danach USB kurz abziehen und wieder einstecken. Erst wenn der Drucker nicht mehr als `RemovableDisk` erscheint, kann `ptouch-print` drucken.
Der Container braucht Zugriff auf USB. In Unraid geht das am einfachsten mit:
- `/dev/bus/usb:/dev/bus/usb`
- `privileged: true`
## Start lokal
```bash
```sh
git clone <repository-url> P-Touch-Web
cd P-Touch-Web
docker compose up --build
```
Danach: <http://localhost:8080>
Then open <http://localhost:8080> (mobile view: <http://localhost:8080/mobile>).
For Unraid there is `unraid-template.xml`; a variant without a custom image
(mounting the project into `python:3.12-alpine`) is described in
[docs/DETAILS.md](docs/DETAILS.md) (German).
Mobile Ansicht: <http://localhost:8080/mobile>
## Configuration
Beim Dockerfile-Image startet der Container ueber `/usr/local/bin/ptouch-web-start`. Bei der Unraid-GUI-Variante ohne eigenes Image wird stattdessen `sh /srv/ptouch-web/start.sh` als Container-Befehl gesetzt.
| Variable | Default | Meaning |
|---|---|---|
| `PRINT_ENABLED` | `1` | `0` only renders a PNG, `1` prints |
| `PRINT_COMMAND` | `ptouch-print --image {image}` | print command; `{image}` is replaced, `{cut_args}` optional |
| `LABEL_DPI` | `180` | matches the PT-P700 |
| `LABEL_DIR` | `./labels` | rendered PNGs and the print queue (`queue/`); mount persistently |
| `PRINT_QUEUE_ENABLED` | `1` | queue jobs and print once the printer is reachable |
| `PRINT_QUEUE_RETRY_SECONDS` | `30` | retry interval for queued jobs |
| `SECRET_KEY` | `change-me` | Flask session key, **set your own value** |
## Unraid Docker-GUI ohne eigenes Image
## Usage
Diese Variante nutzt ein fertiges Alpine/Python-Basisimage und mountet dieses Projekt in den Container. `start.sh` installiert beim Start Flask, Pillow und baut `ptouch-print`.
Design the label in the browser, check the preview and print. The PT-P700
supports full cuts and chain printing but no half cut; "chain print / strip"
renders several copies as one long image without full cuts in between.
Nachteil: Beim ersten Start braucht der Container Internet und der Start dauert laenger. Nach einem Container-Neuerstellen kann das erneut passieren.
Test the USB connection inside the container with `ptouch-print --info`.
Troubleshooting for `PLite Mode`, `LIBUSB_ERROR_IO` and the `usblp` kernel
module: [docs/DETAILS.md](docs/DETAILS.md).
Dateien auf Unraid ablegen:
## Security
```text
/mnt/user/appdata/ptouch-web/app
/mnt/user/appdata/ptouch-web/start.sh
/mnt/user/appdata/ptouch-web/requirements.txt
/mnt/user/appdata/ptouch-web/labels
```
The app has no login. Run it only in a trusted network or behind a reverse
proxy with authentication, and set `SECRET_KEY`. The container is privileged
because it needs raw USB access.
In Unraid: Docker -> Add Container.
## License
1. `Name`: `ptouch-web`
2. `Repository`: `python:3.12-alpine`
3. `Network Type`: `bridge`
4. `Privileged`: `On`
5. `Post Arguments`: `sh /srv/ptouch-web/start.sh`
6. `Console shell command` ist egal
7. Bei `Command` oder `Entrypoint`, falls sichtbar:
- `Command`: leer lassen, wenn `Post Arguments` gesetzt ist
- `Entrypoint`: leer
8. Port hinzufuegen:
- Container Port: `8080`
- Host Port: `8080`
- Protocol: `TCP`
9. Path hinzufuegen fuer die App:
- Container Path: `/srv/ptouch-web`
- Host Path: `/mnt/user/appdata/ptouch-web`
- Access Mode: `Read/Write`
10. Path hinzufuegen:
- Container Path: `/data/labels`
- Host Path: `/mnt/user/appdata/ptouch-web/labels`
- Access Mode: `Read/Write`
11. Path hinzufuegen fuer USB:
- Container Path: `/dev/bus/usb`
- Host Path: `/dev/bus/usb`
- Access Mode: `Read/Write`
12. Variablen hinzufuegen:
- `APP_DIR=/srv/ptouch-web`
- `FLASK_APP=app.app`
- `PRINT_ENABLED=1`
- `PRINT_COMMAND=ptouch-print --image {image}`
- `LABEL_DIR=/data/labels`
- `LABEL_DPI=180`
Wichtig: `/srv/ptouch-web` muss den Inhalt dieses Projektordners enthalten, also direkt `app/`, `start.sh` und `requirements.txt`.
## Konfiguration
Umgebungsvariablen:
- `PRINT_ENABLED=1` druckt wirklich. Mit `0` wird nur ein PNG erzeugt.
- `PRINT_COMMAND=ptouch-print --image {image}` ist das Druckkommando.
- `LABEL_DPI=180` passt zum PT-P700.
- `LABEL_DIR=/data/labels` speichert erzeugte PNG-Dateien.
- `PRINT_QUEUE_ENABLED=1` legt Druckauftraege zuerst in eine Warteschlange und druckt sie, sobald der Drucker erreichbar ist.
- `PRINT_QUEUE_RETRY_SECONDS=30` legt fest, wie oft wartende Jobs erneut versucht werden.
Wenn `ptouch-print` auf deinem Setup andere Optionen braucht, nur `PRINT_COMMAND` anpassen. Der Platzhalter `{image}` wird von der App ersetzt. Fuer Schnittoptionen kannst du optional `{cut_args}` im Kommando platzieren; ohne Platzhalter haengt die App die Schnittargumente automatisch an.
Die Druckwarteschlange liegt unter `/data/labels/queue`. Deshalb muss `/data/labels` persistent gemountet sein, wenn Jobs einen Container-Neustart ueberleben sollen.
Hinweis: Der PT-P700 unterstuetzt laut Brother Auto Cut und Kettendruck, aber keinen Halbschnitt. Die Option `Kettendruck / Streifen` rendert mehrere Kopien als ein langes Druckbild, damit keine Vollschnitte zwischen den Labels entstehen.
Die automatische Laenge entfernt leeres Band am Ende des Etiketts. Links bzw. oben bleibt das Layout unveraendert, damit die Positionen im Editor nachvollziehbar bleiben.
## USB testen
Im laufenden Container:
```bash
ptouch-print --info
```
Wenn kein Drucker gefunden wird, zuerst pruefen:
- Ist Editor Lite deaktiviert?
- Sieht Unraid den Drucker unter USB?
- Ist `/dev/bus/usb` im Container sichtbar?
- Laeuft der Container privilegiert?
Wenn `ptouch-print` meldet:
```text
PT-P700 (PLite Mode) found
```
ist Editor Lite noch aktiv. Das ist kein Containerproblem, sondern der USB-Modus des Druckers.
Wenn `ptouch-print` meldet:
```text
PT-P700 found on USB bus ..., device ...
libusb_open error :LIBUSB_ERROR_IO
```
sieht der Container den Drucker, kann ihn aber nicht oeffnen. Dann pruefen:
- Container in Unraid wirklich mit `Privileged: On` starten.
- `/dev/bus/usb` als Pfad `Read/Write` nach `/dev/bus/usb` mounten.
- Keine zusaetzliche Device-Zeile nur fuer `/dev/usb/lp0` verwenden.
- Auf dem Unraid-Host pruefen, ob `usblp` geladen ist: `lsmod | grep usblp`
- Falls `usblp` geladen ist, testweise entladen: `modprobe -r usblp`
- USB-Kabel danach kurz abziehen und wieder einstecken.
Wenn das Entladen von `usblp` hilft, sollte `usblp` auf dem Host dauerhaft fuer diesen Drucker deaktiviert werden, weil `ptouch-print` direkt ueber libusb druckt.
Wenn `usblp` entladen ist und `LIBUSB_ERROR_IO` trotzdem bleibt:
1. Im Container-Terminal pruefen:
```bash
lsusb
ls -l /dev/bus/usb/001/020
ptouch-print --info
```
Die Bus-/Device-Nummer muss zur Ausgabe von `lsusb` passen.
2. Auf dem Unraid-Host pruefen, ob ein Prozess das USB-Device offen hat:
```bash
fuser -v /dev/bus/usb/001/020
lsof /dev/bus/usb/001/020 2>/dev/null
```
3. Unraid-Container-Konfiguration pruefen:
- `Privileged: On`
- `/dev/bus/usb` als `Path`, nicht nur als Datei, nach `/dev/bus/usb`
- Access Mode `Read/Write`
- keine extra `/dev/usb/lp0`-Device-Zuordnung
4. Wenn die Device-Nummer nach USB-Neustecken anders ist, die Befehle mit der neuen Nummer wiederholen.
MIT, see [LICENSE](LICENSE).