No project description provided
Project description
ptouch-template
ptouch-template is a CLI application which facilitates creation of DXF ptouch templates, and the printing from them.
It is built on top of the ezdxf and ptouch libraries.
And also requires the optional ezdxf dependencies Pillow and matplotlib.
Installation
uv tool install 'ptouch-template[usb,snmp]'
The usb dependency is required to print over usb.
The snmp dependency allows the script to read the installed tape width to prevent you from printing with a template for a different size tape. Requires the printer to have networking.
You can print over usb, and still use the SNMP link to verify the tape width.
I've noticed that the heathshrink tube 3:1 21mm tape mistakenly reports 24mm tape width over SNMP. If that happens you can pass --no-snmp-check to disable the check during printing.
Usage
> ptouch-template --help
usage: ptouch-template [-h] [--debug] [--templates TEMPLATES] [--host IP |
--usb [URI]]
[--printer {E550W,P750W,P900,P900W,P910BT,P950NW}]
[--no-compression]
{print,create,list,describe,show-config,save-config} ...
options:
-h, --help show this help message and exit
--debug, -d Create images instead of printing them
--templates, -t TEMPLATES
Template folder
--host, -H IP Printer IP address for network connection
--usb [URI] Use USB connection. Optional URI:
usb://[vendor:]product[/serial] (e.g.,
usb://:0x2086/A1B2C3D4E5)
--printer, -p {E550W,P750W,P900,P900W,P910BT,P950NW}
Printer model
--no-compression Disable TIFF compression
Command:
{print,create,list,describe,show-config,save-config}
print Print one or more labels from a template
create Create a template
list List available templates
describe List the print options and placeholders in a template
show-config Show the current configuration
save-config Save the current arguments to the config file, so you
won't have to specify them next time
> ptouch-template create --help
usage: ptouch-template create [-h] (--tape-width {3.5,6,9,12,18,24,36} |
--tube-width {5.8,8.8,11.7,17.7,23.6,5.2,9.0,11.2,21.0,31.0})
--length LENGTH [--high-resolution]
[--margin MM] [--no-feed] [--full-cut |
--no-cut | --mark]
name
Create a template.
The tape or tube width must be provided.
The configured printer will then determine the height of the printable area.
Also the desired length of the label must be provided.
This area will be marked in the template with a (not printed) yellow rectangle.
There will be a blank margin to either side of this rectangle.
When printing with cutting it can be no less than, and defaults to, 2mm.
When printing with --no-cut or --mark it can be less, or even zero.
Default cutting behavior:
* A half cut will be made between labels.
The --full-cut, --no-cut, and --mark flags can be used to change this.
* A final full cut will be made.
Add the --no-feed flag to replace the cut with a vertical 1px line.
This flag requires either --no-cut or --mark to be provided as well.
You will then need to physically remove the tape and cut it manually.
Tape notes:
* Non-laminated tapes cannot be half cut, so always use one of the cut options
--full-cut, --no-cut, or --mark
* It is recommended to use --no-cut with heatshrink tapes to save the cutter
* And to not half cut extra strong adhesive tapes to avoid adhesive buildup
When editing the template:
* Do not remove the yellow rectangle, and do not put anything outside of it
* Add "{<placeholder>}" texts to be replaced during printing
(fi. "{first_name} {last_name}", without the surrounding double quotes)
* If you want to be able to replace placeholers with multi-line texts,
make sure to use a multi-line DXF text (MTEXT instead of TEXT)
positional arguments:
name Name of the template
options:
-h, --help show this help message and exit
--tape-width, -t {3.5,6,9,12,18,24,36}
Laminated tape width in mm
--tube-width, -T {5.8,8.8,11.7,17.7,23.6,5.2,9.0,11.2,21.0,31.0}
Heat shrink tube diameter in mm
(2:1: 5.8/8.8/11.7/17.7/23.6,
3:1: 5.2/9.0/11.2/21.0/31.0)
--length, -l LENGTH Label length in mm
--high-resolution Enable high resolution mode
--margin, -m MM Margin in mm (default, and minimum when cutting: 2mm)
--no-feed Do not feed and cut after the last label (requires
either --no-cut or --mark)
--full-cut Use full cuts between labels instead of half cuts
(recommended for strong adhesive tapes)
--no-cut Do not cut at all between labels (e.g. for patch
panels)
--mark Add a vertical line between labels instead of cutting
> ptouch-template print --help
usage: ptouch-template print [-h] [--csv CSV] [--copies N] [--no-snmp-check]
template [contents ...]
Print one or more labels from a template.
Pass the name of the template or a path to a DXF file saved from a template,
and, if the template has placeholders, one of:
* --csv: a path to a CSV file with a row per label and the columns named after
the placeholders
* one or more contents:
- for templates with a single placeholder each string prints a label
- for templates with multiple placeholders a series of <placeholder>=<text>
strings (you can only print a single label with multiple placeholders)
positional arguments:
template Name of a template or a path to a DXF file saved from a
template
contents Mutually exclusive with --csv. When the template has no
placeholders: do not pass contents. When the template
has just one placeholder: pass one string per label.
When the template has multiple placeholders: pass one
"<placeholder>=<text>" string per placeholder (you can
only print one label with multiple placeholders, use
--csv instead of contents to print multiple labels).
options:
-h, --help show this help message and exit
--csv CSV Path to a CSV file with a row per label and columns
named after placeholders
--copies, -c N Number of copies to print (default: 1)
--no-snmp-check, -n Do not check installed media width with SNMP
Development
Setup the virtualenv:
uv sync --all-extras --all-groups
Install the project:
uv tool install --editable '.[usb,snmp]'
Build and publish:
uv version <version>
git commit
git tag v<version>
git push
git push --tags
rm -rf dist
uv build
uv publish --token <token>
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ptouch_template-1.1.0.tar.gz.
File metadata
- Download URL: ptouch_template-1.1.0.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3fac091dca7a30edbb1a36ba57e5cb7e03ae658ac2f6190da28d631529f0e34
|
|
| MD5 |
c45dbd085a8874c3336f64e5854a6d33
|
|
| BLAKE2b-256 |
4fc3724fe795ff41f4b79b9743ca606beed8abbdd7b675ccaca5c9278dbec9d2
|
File details
Details for the file ptouch_template-1.1.0-py3-none-any.whl.
File metadata
- Download URL: ptouch_template-1.1.0-py3-none-any.whl
- Upload date:
- Size: 14.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d541e28d97e6b961f65a1b1ac5580a077a857d8566ffbba1fa6edb489c705de8
|
|
| MD5 |
19494a39533981ad93faaf0199890a75
|
|
| BLAKE2b-256 |
45e93513837a662e602c8f0ce0ef6f5ddab68a79b5640ef90704597a598e1f32
|