print checkbox

This commit is contained in:
2025-12-05 21:41:52 +01:00
parent 6dda384428
commit b3eaafbbe5
2 changed files with 50 additions and 7 deletions

View File

@ -49,7 +49,7 @@ class DriveData:
@dataclasses.dataclass
class DriveDataJson:
state: str
connection_type: str
contype: str
fam: str
name: str
cap: int
@ -153,17 +153,19 @@ def format_to_printable(drive):
cut_string(30, str(datetime.timedelta(seconds=drive.shred_duration)), "end"),
)
def draw_text(drawable, printable_data, font_regular, font_bold, font_bold_bigger):
"""Draws formatted text with Cycles and Errors on one row."""
y_start = 4
line_height = 26
label_x = TEXT_X_OFFSET
value_offset = 115
right_field_spacing = 200 # Horizontal gap between Cycles and Errors
x_capacity = 520
y_capacity = 142
y_start = 4
x_connection_type = 600
y_connection_type = y_start
y_spacing_connection_type = 25
# Serial Number
drawable.text((label_x, y_start), "Serial:", fill=0, font=font_bold)
@ -250,6 +252,49 @@ def draw_text(drawable, printable_data, font_regular, font_bold, font_bold_bigge
font=font_bold_bigger,
)
if (printable_data.connectiontype == "sata"):
drawable.text(
(x_connection_type, y_connection_type),
"⬤ SATA",
fill=0,
font=font_regular,
)
drawable.text(
(x_connection_type, y_connection_type+y_spacing_connection_type),
"◯ NVME",
fill=0,
font=font_regular,
)
elif (printable_data.connectiontype == "nvme"):
drawable.text(
(x_connection_type, y_connection_type),
"◯ SATA",
fill=0,
font=font_regular,
)
drawable.text(
(x_connection_type, y_connection_type+y_spacing_connection_type),
"⬤ NVME",
fill=0,
font=font_regular,
)
else:
drawable.text(
(x_connection_type, y_connection_type),
"◯ SATA",
fill=0,
font=font_regular,
)
drawable.text(
(x_connection_type, y_connection_type+y_spacing_connection_type),
"◯ NVME",
fill=0,
font=font_regular,
)
def draw_qr_code(image, data):
"""
@ -274,7 +319,6 @@ def draw_qr_code(image, data):
region = (5, 5, 5 + QR_CODE_SIZE, 5 + QR_CODE_SIZE)
image.paste(qr_img, box=region)
def draw_outline(drawable, margin, width, output_width, output_height):
"""
Draws a rectangular outline on the drawable canvas.
@ -303,14 +347,13 @@ def draw_outline(drawable, margin, width, output_width, output_height):
for line in lines:
drawable.line(line, fill=0, width=width)
def generate_image(drive, rehdd_info, output_file):
"""Generates an image containing drive data and a QR code."""
try:
drive_json = DriveDataJson(
state=drive.drive_state,
connection_type=drive.drive_connection_type,
contype=drive.drive_connection_type,
fam=drive.modelfamily,
name=drive.modelname,
cap=drive.capacity,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB