Display printable tape width

This commit is contained in:
Mikei386
2026-06-22 14:45:18 +02:00
parent d00ce6fe90
commit fb82c16233
6 changed files with 21 additions and 1 deletions
+8
View File
@@ -444,6 +444,13 @@ def media_type_from_output(output: str) -> dict[str, str] | None:
}
def printable_width_from_output(output: str) -> int | None:
match = re.search(r"maximum printing width[^\n]*?(\d+)\s*px", output, re.IGNORECASE)
if not match:
return None
return int(match.group(1))
def detect_tape_info() -> dict[str, Any]:
result = subprocess.run(
["ptouch-print", "--info"],
@@ -472,6 +479,7 @@ def detect_tape_info() -> dict[str, Any]:
return {
"width": width,
"printableWidthPx": printable_width_from_output(output),
"mediaType": media_type_from_output(output),
"tapeColor": color_info_from_line(output, "tape color"),
"textColor": color_info_from_line(output, "text color"),