qltool 0.2.4__tar.gz → 0.2.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 0.2.4
2
+ current_version = 0.2.6
3
3
  commit = True
4
4
  tag = True
5
5
 
qltool-0.2.6/PKG-INFO ADDED
@@ -0,0 +1,152 @@
1
+ Metadata-Version: 2.4
2
+ Name: qltool
3
+ Version: 0.2.6
4
+ Summary: PRINT simple labels on ql700
5
+ Requires-Python: >=3.10
6
+ Requires-Dist: click>=8.2.1
7
+ Requires-Dist: console>=0.9911
8
+ Requires-Dist: importlib-resources>=6.5.2
9
+ Requires-Dist: opencv-python>=4.12.0.88
10
+ Requires-Dist: paho-mqtt>=2.1.0
11
+ Requires-Dist: pillow>=11.3.0
12
+ Requires-Dist: qrcode>=8.2
13
+ Description-Content-Type: text/markdown
14
+
15
+ # qltool 0.2.4
16
+
17
+ *Tool to print labels with Brother QL-700/QL-570 label printer*
18
+
19
+ A wrapper around the excellent `ql570.c` by Asbjørn Sloth Tønnesen, Marc Juul and Luca Zimmermann.
20
+
21
+ ## Features
22
+
23
+ - Print text labels (1-3 lines)
24
+ - Print QR codes with text
25
+ - Print banners (text along paper length)
26
+ - Custom font sizes
27
+ - MQTT client for remote printing
28
+ - Preview before printing
29
+
30
+ ## Installation
31
+
32
+ Using `uv` (recommended):
33
+
34
+ ```bash
35
+ uv pip install -e .
36
+ ```
37
+
38
+ Or with pip:
39
+
40
+ ```bash
41
+ pip3 install qltool
42
+ ```
43
+
44
+ ## Usage
45
+
46
+ ### Standard Label Print
47
+
48
+ Print 1-3 lines of text:
49
+
50
+ ```bash
51
+ # Preview only
52
+ uv run src/qltool/main.py "Line 1" "Line 2" "Line 3" --font-size 40
53
+
54
+ # Print with specific font size
55
+ uv run src/qltool/main.py "Hello World" "Second line" -p --font-size 55
56
+ ```
57
+
58
+ ### QR Code Labels
59
+
60
+ ```bash
61
+ # Generate and print QR code with text
62
+ uv run src/qltool/main.py "Item: 12345" "Location: Office" -q -p
63
+
64
+ # Use existing QR image
65
+ uv run src/qltool/main.py "Scan me" --qr /path/to/qrcode.png -p
66
+ ```
67
+
68
+ ### Banner Mode (Text along paper length)
69
+
70
+ ```bash
71
+ # Preview banner
72
+ uv run src/qltool/main.py "Long text banner" --banner --font-size 40
73
+
74
+ # Print banner
75
+ uv run src/qltool/main.py "STS Chvojkovice-Brod" --banner --font-size 40 -p
76
+ ```
77
+
78
+ ### Command Options
79
+
80
+ - `-p, --print` - Send to printer (without this, shows preview)
81
+ - `-q, --qr` - Generate QR code
82
+ - `--qr PATH` - Use existing QR image
83
+ - `--banner` - Create banner (text along paper length)
84
+ - `--font-size N` - Set font size (default: 72)
85
+ - `--width N` - Set image width in pixels (default: 714 for 62mm tape)
86
+ - `--gray N` - Gray bias 0-100 (default: 50)
87
+ - `-d, --device` - Specify printer device (default: auto-detect /dev/usb/lp*)
88
+
89
+ ## MQTT Client
90
+
91
+ Run the MQTT client for remote printing:
92
+
93
+ ```bash
94
+ qltool_client
95
+ ```
96
+
97
+ Send print jobs via MQTT:
98
+
99
+ ```bash
100
+ # Simple print
101
+ mosquitto_pub -t qltool/print -m "Hello World -p"
102
+
103
+ # With QR code
104
+ mosquitto_pub -t qltool/print -m "Inventory Item -q -p"
105
+
106
+ # Banner
107
+ mosquitto_pub -t qltool/print -m "Long banner text --banner -p"
108
+ ```
109
+
110
+ ## Development
111
+
112
+ Run directly from source:
113
+
114
+ ```bash
115
+ # Preview
116
+ uv run src/qltool/main.py "Test text" --font-size 40
117
+
118
+ # Print
119
+ uv run src/qltool/main.py "Test text" --font-size 40 -p
120
+ ```
121
+
122
+ ## Requirements
123
+
124
+ - Brother QL-700 or QL-570 printer
125
+ - User must be in `lp` group for printer access
126
+ - Linux with USB lp device support (`/dev/usb/lp*`)
127
+
128
+ ## Org-mode Integration (Inventory)
129
+
130
+ For Emacs org-mode table integration:
131
+
132
+ ```elisp
133
+ ;; Add to .emacs
134
+ (defun print-inventory-item ()
135
+ "Print current org table row as label"
136
+ (interactive)
137
+ ;; Your implementation here
138
+ )
139
+ ```
140
+
141
+ Example table format:
142
+
143
+ | ID | Name | Owner | Location |
144
+ |-------------|-----------------------------|-------|----------|
145
+ | D4-12345678 | Sample inventory item | Pepa | Home |
146
+
147
+ The tool can extract ID and name fields to generate QR-coded inventory labels.
148
+
149
+ ## Credits
150
+
151
+ - `ql570.c` driver by Asbjørn Sloth Tønnesen, Marc Juul and Luca Zimmermann
152
+ - Built with Python, Click, Pillow, and OpenCV
qltool-0.2.6/README.md ADDED
@@ -0,0 +1,138 @@
1
+ # qltool 0.2.4
2
+
3
+ *Tool to print labels with Brother QL-700/QL-570 label printer*
4
+
5
+ A wrapper around the excellent `ql570.c` by Asbjørn Sloth Tønnesen, Marc Juul and Luca Zimmermann.
6
+
7
+ ## Features
8
+
9
+ - Print text labels (1-3 lines)
10
+ - Print QR codes with text
11
+ - Print banners (text along paper length)
12
+ - Custom font sizes
13
+ - MQTT client for remote printing
14
+ - Preview before printing
15
+
16
+ ## Installation
17
+
18
+ Using `uv` (recommended):
19
+
20
+ ```bash
21
+ uv pip install -e .
22
+ ```
23
+
24
+ Or with pip:
25
+
26
+ ```bash
27
+ pip3 install qltool
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ ### Standard Label Print
33
+
34
+ Print 1-3 lines of text:
35
+
36
+ ```bash
37
+ # Preview only
38
+ uv run src/qltool/main.py "Line 1" "Line 2" "Line 3" --font-size 40
39
+
40
+ # Print with specific font size
41
+ uv run src/qltool/main.py "Hello World" "Second line" -p --font-size 55
42
+ ```
43
+
44
+ ### QR Code Labels
45
+
46
+ ```bash
47
+ # Generate and print QR code with text
48
+ uv run src/qltool/main.py "Item: 12345" "Location: Office" -q -p
49
+
50
+ # Use existing QR image
51
+ uv run src/qltool/main.py "Scan me" --qr /path/to/qrcode.png -p
52
+ ```
53
+
54
+ ### Banner Mode (Text along paper length)
55
+
56
+ ```bash
57
+ # Preview banner
58
+ uv run src/qltool/main.py "Long text banner" --banner --font-size 40
59
+
60
+ # Print banner
61
+ uv run src/qltool/main.py "STS Chvojkovice-Brod" --banner --font-size 40 -p
62
+ ```
63
+
64
+ ### Command Options
65
+
66
+ - `-p, --print` - Send to printer (without this, shows preview)
67
+ - `-q, --qr` - Generate QR code
68
+ - `--qr PATH` - Use existing QR image
69
+ - `--banner` - Create banner (text along paper length)
70
+ - `--font-size N` - Set font size (default: 72)
71
+ - `--width N` - Set image width in pixels (default: 714 for 62mm tape)
72
+ - `--gray N` - Gray bias 0-100 (default: 50)
73
+ - `-d, --device` - Specify printer device (default: auto-detect /dev/usb/lp*)
74
+
75
+ ## MQTT Client
76
+
77
+ Run the MQTT client for remote printing:
78
+
79
+ ```bash
80
+ qltool_client
81
+ ```
82
+
83
+ Send print jobs via MQTT:
84
+
85
+ ```bash
86
+ # Simple print
87
+ mosquitto_pub -t qltool/print -m "Hello World -p"
88
+
89
+ # With QR code
90
+ mosquitto_pub -t qltool/print -m "Inventory Item -q -p"
91
+
92
+ # Banner
93
+ mosquitto_pub -t qltool/print -m "Long banner text --banner -p"
94
+ ```
95
+
96
+ ## Development
97
+
98
+ Run directly from source:
99
+
100
+ ```bash
101
+ # Preview
102
+ uv run src/qltool/main.py "Test text" --font-size 40
103
+
104
+ # Print
105
+ uv run src/qltool/main.py "Test text" --font-size 40 -p
106
+ ```
107
+
108
+ ## Requirements
109
+
110
+ - Brother QL-700 or QL-570 printer
111
+ - User must be in `lp` group for printer access
112
+ - Linux with USB lp device support (`/dev/usb/lp*`)
113
+
114
+ ## Org-mode Integration (Inventory)
115
+
116
+ For Emacs org-mode table integration:
117
+
118
+ ```elisp
119
+ ;; Add to .emacs
120
+ (defun print-inventory-item ()
121
+ "Print current org table row as label"
122
+ (interactive)
123
+ ;; Your implementation here
124
+ )
125
+ ```
126
+
127
+ Example table format:
128
+
129
+ | ID | Name | Owner | Location |
130
+ |-------------|-----------------------------|-------|----------|
131
+ | D4-12345678 | Sample inventory item | Pepa | Home |
132
+
133
+ The tool can extract ID and name fields to generate QR-coded inventory labels.
134
+
135
+ ## Credits
136
+
137
+ - `ql570.c` driver by Asbjørn Sloth Tønnesen, Marc Juul and Luca Zimmermann
138
+ - Built with Python, Click, Pillow, and OpenCV
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "qltool"
3
- version = "0.2.4"
3
+ version = "0.2.6"
4
4
  description = "PRINT simple labels on ql700"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -63,10 +63,19 @@ def is_user_in_lp_group():
63
63
  #
64
64
  # ----------------------------------------------------------------------
65
65
  def get_data_path():
66
- #src = files("data").joinpath("ql570")
67
- src = files("qltool").joinpath("data", "ql570")
68
- with as_file(src) as p:
69
- return str(p)
66
+ """Get path to ql570 binary, works both when installed and run directly."""
67
+ try:
68
+ # Try installed package first
69
+ src = files("qltool").joinpath("data", "ql570")
70
+ with as_file(src) as p:
71
+ return str(p)
72
+ except Exception:
73
+ # Fall back to relative path when running directly
74
+ # __file__ is src/qltool/main.py, data is in src/qltool/data/
75
+ fallback = os.path.join(os.path.dirname(__file__), "data", "ql570")
76
+ if os.path.exists(fallback):
77
+ return fallback
78
+ raise
70
79
 
71
80
  # =====================================================================
72
81
  #
@@ -205,6 +214,57 @@ def rotate_mono_90(img, clockwise=True):
205
214
  return img.transpose(Image.ROTATE_270 if clockwise else Image.ROTATE_90)
206
215
 
207
216
 
217
+ # =====================================================================
218
+ #
219
+ # ----------------------------------------------------------------------
220
+ def make_banner_image(text, paper_width=714, font_size=None, pad=13):
221
+ """
222
+ Create a banner image with text running along the paper length.
223
+
224
+ Creates a horizontal text image with dimensions (text_length x 714).
225
+ This is NOT rotated - sent to printer as-is so text prints along paper length.
226
+
227
+ - text: single string (arbitrary length)
228
+ - paper_width: width of the paper (714px for 62mm) - used as height here
229
+ - font_size: font size (uses CLI font_size or default)
230
+ - pad: padding around text
231
+
232
+ Returns a PIL.Image in RGB mode with dimensions (text_length x 714).
233
+ """
234
+ FSIZ = font_size or 36
235
+ try:
236
+ font = ImageFont.truetype(FONT_PATH, FSIZ) if FONT_PATH else ImageFont.load_default()
237
+ except Exception:
238
+ font = ImageFont.load_default()
239
+
240
+ PAD = int((FSIZ / 36) * pad)
241
+
242
+ # Measure the text
243
+ tmp = Image.new("L", (10000, 1000), 255)
244
+ draw_tmp = ImageDraw.Draw(tmp)
245
+ bbox = draw_tmp.textbbox((0, 0), text, font=font)
246
+ text_width = bbox[2] - bbox[0]
247
+ text_height = bbox[3] - bbox[1]
248
+ print(f"D... Banner text measurements: text_width={text_width}, text_height={text_height}, PAD={PAD}")
249
+
250
+ # Create horizontal text image: width = text length + padding, height = paper width
251
+ # Banners are NOT rotated - they are sent to printer as-is with height=714
252
+ img_width = int(text_width + PAD * 2)
253
+ img_height = int(paper_width)
254
+ print(f"D... Banner image dimensions: {img_width}x{img_height} (NOT rotated, height stays 714)")
255
+
256
+ im = Image.new("RGB", (img_width, img_height), "white")
257
+ draw = ImageDraw.Draw(im)
258
+
259
+ # Center the text vertically
260
+ x = PAD
261
+ y = (img_height - text_height) // 2
262
+
263
+ draw.text((x, y), text, font=font, fill=0)
264
+
265
+ return im
266
+
267
+
208
268
 
209
269
 
210
270
  # =====================================================================
@@ -355,17 +415,19 @@ def make_bw_text_with_qr(lines,
355
415
  @click.option("--qr", "qr_path", default=None, show_default=True, help="QR image path.")
356
416
  @click.option("-q", "qr_create", is_flag=True, default=False, show_default=True, help="do QR")
357
417
  @click.option("--address", "address", default=None, show_default=True, help="Address/URL to encode in QR code.")
358
- def cli(lines, do_print, device, fmt, width, gray, font_size, qr_path, qr_create, address):
418
+ @click.option("--banner", "banner", is_flag=True, default=False, show_default=True, help="Create a banner with text along the paper length.")
419
+ def cli(lines, do_print, device, fmt, width, gray, font_size, qr_path, qr_create, address, banner):
359
420
  """
360
421
  Create a black-on-white PNG from 1-3 lines of text.
361
422
  By default displays the image with OpenCV. Use -p to print via ql570.
423
+ Use --banner to create a long text banner along the paper length.
362
424
  """
363
425
  #print(lines, type(lines), len(lines))
364
426
  if type(lines)is not tuple:
365
427
  print("X... the text should be python-tuple for some reason....")
366
428
  sys.exit(1)
367
429
 
368
- if len(lines) > 3: # "A" "B" "C"
430
+ if not banner and len(lines) > 3: # "A" "B" "C"
369
431
  print("Error: max 3 lines allowed.", file=sys.stderr)
370
432
  sys.exit(2)
371
433
 
@@ -377,7 +439,7 @@ def cli(lines, do_print, device, fmt, width, gray, font_size, qr_path, qr_create
377
439
  else:
378
440
  print("Q... lines ...I do not understand")
379
441
 
380
- if len(lines) > 3: # "A" "B" "C"
442
+ if not banner and len(lines) > 3: # "A" "B" "C"
381
443
  print("Error: max 3 lines allowed.", file=sys.stderr)
382
444
  sys.exit(2)
383
445
 
@@ -400,13 +462,26 @@ def cli(lines, do_print, device, fmt, width, gray, font_size, qr_path, qr_create
400
462
  lines = ["\n".join(lines) ] # BACK TO NICE \n
401
463
 
402
464
  im = None
403
- if use_qr_version:
465
+ if banner:
466
+ # Banner mode: single line of text along paper length
467
+ banner_text = lines[0].replace("\n", " ") # Flatten any newlines
468
+ im = make_banner_image(banner_text, paper_width=714, font_size=font_size)
469
+ print(f"D... Banner image size: {im.size}")
470
+ elif use_qr_version:
404
471
  im = make_bw_text_with_qr(list(lines), my_qr_path, width=714, font_size=font_size)
405
472
  else:
406
473
  im = make_bw_text_image(list(lines), width=714, font_size=font_size)
407
474
 
408
475
  mono = convert_to_mono_floyd(im, gray_percent=int(gray))
409
- mono = rotate_mono_90(mono, clockwise=True)
476
+ print(f"D... After convert_to_mono_floyd: {mono.size}")
477
+ # Rotate only normal labels, NOT banners
478
+ # Banners are already created with correct orientation: width=variable, height=714
479
+ if not banner:
480
+ mono = rotate_mono_90(mono, clockwise=True)
481
+ print(f"D... After rotation for normal label: {mono.size}")
482
+ else:
483
+ print(f"D... Banner - keeping original orientation")
484
+ print(f"D... Final mono image size: {mono.size}, mode: {mono.mode}")
410
485
 
411
486
  out = get_tmp_fname()
412
487
  print(f"D.... {out}")
@@ -428,6 +503,8 @@ def cli(lines, do_print, device, fmt, width, gray, font_size, qr_path, qr_create
428
503
  exe = get_data_path()
429
504
  dev = device if device else check_lpx()
430
505
  CMD = f"{exe} {dev} {fmt} {out}"
506
+ print(f"D... Printer command: {CMD}")
507
+ print(f"D... Image file: {out}, size: {mono.size}")
431
508
 
432
509
  if not is_user_in_lp_group():
433
510
  print("X... ", fg.red, "you are not in lp group", fg.default)
qltool-0.2.4/PKG-INFO DELETED
@@ -1,79 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: qltool
3
- Version: 0.2.4
4
- Summary: PRINT simple labels on ql700
5
- Requires-Python: >=3.10
6
- Requires-Dist: click>=8.2.1
7
- Requires-Dist: console>=0.9911
8
- Requires-Dist: importlib-resources>=6.5.2
9
- Requires-Dist: opencv-python>=4.12.0.88
10
- Requires-Dist: paho-mqtt>=2.1.0
11
- Requires-Dist: pillow>=11.3.0
12
- Requires-Dist: qrcode>=8.2
13
- Description-Content-Type: text/markdown
14
-
15
- # qltool 0.1.14
16
-
17
- *tool to print some useful stuff with ql700 brother printer*
18
-
19
- - It is just a wrapper around the great `ql570.c` of Asbjørn Sloth
20
- Tønnesen, Marc Juul and Luca Zimmermann
21
-
22
- ## Installation
23
-
24
- ``` {.bash org-language="sh"}
25
- pip3 install qltool
26
- ```
27
-
28
- ## Usage - standard print
29
-
30
- ``` {.bash org-language="sh"}
31
- #---------text
32
- rm /tmp/tmp_qrcode.png ; uv run src/qltool/main.py "Ahoj
33
- aaa
34
- 456 8jgqy 789 456 456 " --font-size 55 --font-size 45
35
-
36
- # ---- create QR
37
-
38
- uv run src/qltool/main.py "ahoj
39
- momo
40
- 123 456 789 jjj" -p -q
41
-
42
- # -------- use any image/qrcode
43
- uv run src/qltool/main.py "Užaj jetů" --qr /tmp/baba.png
44
-
45
- uv run src/qltool/main.py "Už je tuná" --qr /tmp/baba.png -p
46
- ```
47
-
48
- ## Using mqtt client
49
-
50
- `qltool_client`
51
-
52
- ``` {.bash org-language="sh"}
53
- # DO
54
- qltool_client # somewhere...
55
- ### examples:
56
- export D=`date +"%H:%M:%S"`; mosquitto_pub -t qltool/print -m "hoho $D -q -p"
57
-
58
- # blocking...
59
- mosquitto_pub -t qltool/print -m "hoho secondline thirdline -q "
60
-
61
- # NEVER USE THIS:
62
- watch -n 10 'export D=`date +"%H:%M:%S"`; mosquitto_pub -t qltool/print -m "\"hoho asdas\" \"jeli $D\" -q "'
63
- ```
64
-
65
- ## Org-mode inventory - broken now
66
-
67
- If this function is somewhere in the `.emacs` configfiles ...
68
-
69
- It selects two fields fromthe TABLE and puts -q option.
70
-
71
- You point to a line of a table and `c-c q`{.verbatim} or
72
- `c-c w`{.verbatim} will view/print the code for inventory.
73
-
74
- whatever id name owner location
75
- ---------- ------------- --------------------------- ------- ----------
76
- 123 D4-12345678 najaka blbost z inventury Pepa Home
77
-
78
- and this is run
79
- `./bin_qltool.py "id: D4-12345678; name: najaka blbost z inventury owner:Pepa " -q`
qltool-0.2.4/README.md DELETED
@@ -1,65 +0,0 @@
1
- # qltool 0.1.14
2
-
3
- *tool to print some useful stuff with ql700 brother printer*
4
-
5
- - It is just a wrapper around the great `ql570.c` of Asbjørn Sloth
6
- Tønnesen, Marc Juul and Luca Zimmermann
7
-
8
- ## Installation
9
-
10
- ``` {.bash org-language="sh"}
11
- pip3 install qltool
12
- ```
13
-
14
- ## Usage - standard print
15
-
16
- ``` {.bash org-language="sh"}
17
- #---------text
18
- rm /tmp/tmp_qrcode.png ; uv run src/qltool/main.py "Ahoj
19
- aaa
20
- 456 8jgqy 789 456 456 " --font-size 55 --font-size 45
21
-
22
- # ---- create QR
23
-
24
- uv run src/qltool/main.py "ahoj
25
- momo
26
- 123 456 789 jjj" -p -q
27
-
28
- # -------- use any image/qrcode
29
- uv run src/qltool/main.py "Užaj jetů" --qr /tmp/baba.png
30
-
31
- uv run src/qltool/main.py "Už je tuná" --qr /tmp/baba.png -p
32
- ```
33
-
34
- ## Using mqtt client
35
-
36
- `qltool_client`
37
-
38
- ``` {.bash org-language="sh"}
39
- # DO
40
- qltool_client # somewhere...
41
- ### examples:
42
- export D=`date +"%H:%M:%S"`; mosquitto_pub -t qltool/print -m "hoho $D -q -p"
43
-
44
- # blocking...
45
- mosquitto_pub -t qltool/print -m "hoho secondline thirdline -q "
46
-
47
- # NEVER USE THIS:
48
- watch -n 10 'export D=`date +"%H:%M:%S"`; mosquitto_pub -t qltool/print -m "\"hoho asdas\" \"jeli $D\" -q "'
49
- ```
50
-
51
- ## Org-mode inventory - broken now
52
-
53
- If this function is somewhere in the `.emacs` configfiles ...
54
-
55
- It selects two fields fromthe TABLE and puts -q option.
56
-
57
- You point to a line of a table and `c-c q`{.verbatim} or
58
- `c-c w`{.verbatim} will view/print the code for inventory.
59
-
60
- whatever id name owner location
61
- ---------- ------------- --------------------------- ------- ----------
62
- 123 D4-12345678 najaka blbost z inventury Pepa Home
63
-
64
- and this is run
65
- `./bin_qltool.py "id: D4-12345678; name: najaka blbost z inventury owner:Pepa " -q`
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes