Display printable tape width
This commit is contained in:
@@ -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"),
|
||||
|
||||
Reference in New Issue
Block a user