Skip to content

Commit 2c22534

Browse files
committed
Accept single or multiple text args
1 parent 56d72bc commit 2c22534

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ usage: printlabel.py [-h] [-u] [-l] [-s] [-c] [-i FILE_NAME] [-M FILE_NAME] [-R
3737
[--fill-color FILL] [--stroke-fill STROKE_FILL]
3838
[--stroke-width STROKE_WIDTH] [--text-size MILLIMETERS]
3939
[--white-level NUMBER] [--threshold NUMBER]
40-
COM_PORT FONT_NAME TEXT_TO_PRINT
40+
COM_PORT FONT_NAME TEXT_TO_PRINT [TEXT_TO_PRINT ...]
4141
4242
positional arguments:
4343
COM_PORT Printer COM port.

printlabel.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def set_args():
2727
p.add_argument(
2828
'text_to_print',
2929
metavar='TEXT_TO_PRINT',
30+
nargs='+',
3031
help='Text to be printed. UTF8 characters are accepted.'
3132
)
3233
p.add_argument(
@@ -235,11 +236,10 @@ def main():
235236
font_size = 0
236237
font_height = 0
237238
print_border = (height_of_the_image - height_of_the_printable_area) / 2
238-
if args.text_to_print:
239+
text = " ".join(args.text_to_print)
240+
if text:
239241
if args.unicode:
240-
text = args.text_to_print.encode().decode('unicode_escape')
241-
else:
242-
text = args.text_to_print
242+
text = text.encode().decode('unicode_escape')
243243
stop = False
244244
while font_height != height_of_the_printable_area:
245245
if font_height > height_of_the_printable_area:

0 commit comments

Comments
 (0)