-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlabel_creating.py
More file actions
36 lines (30 loc) · 1.29 KB
/
label_creating.py
File metadata and controls
36 lines (30 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from blabel import LabelWriter
from pathlib import Path
def print_label(caption: str = "", codecontent:str | None = None, longcaption: str | None = None, icon: str | None = None, height=18):
current_dir = Path(__file__).parent
label_writer = LabelWriter(
str(current_dir / "static" / "Flex_Label.html"),
default_stylesheets=(str(current_dir / "static" / "flex_style.css"),),
)
path=str(current_dir / "static" / "print.pdf")
"""Adds a label to the list to be printed
:param caption: The caption for the label
:param codecontent: The content for the QR code, if None, no QR code is generated
:param longcaption: A longer caption for the label, if None, no long caption is displayed
:param icon: An icon to be displayed on the label, if None, no icon is displayed
:param height: The height of the label in mm, default is 18mm
"""
records = []
if codecontent is not None and icon is not None:
raise ValueError("Cannot have both codecontent and icon at the same time")
records.append(
dict(
caption=caption,
qr_text=codecontent,
longcaption=longcaption,
icon=icon,
user_height=height,
)
)
label_writer.write_labels(records, target=path)
records = []