From a5624542813b93f4632c0473add5d527223bf981 Mon Sep 17 00:00:00 2001 From: belono Date: Sat, 25 Jan 2025 20:22:57 +0100 Subject: [PATCH] Add software_colums example --- examples/software_columns.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 examples/software_columns.py diff --git a/examples/software_columns.py b/examples/software_columns.py new file mode 100644 index 0000000..a89e1d4 --- /dev/null +++ b/examples/software_columns.py @@ -0,0 +1,25 @@ +""" Example for software_columns: Print text arranged into columns.""" + +from escpos import printer + +p = printer.Dummy(profile="TM-U220") + +font = "a" +p.set(font=font) + +# Default: Automatic column width given the characters per line of the printer. +text_list = ["col1", "col2", "col3"] +charsxline = p.profile.get_columns(font) +p.software_columns(text_list=text_list, widths=charsxline, align="center") + +# Tuning some columns: +text_list = ["col1", "col2", "col3"] +widths = [5, 20] # col1 = 5 chars width, col2 + col3 = 20 chars width +align = ["left", "center"] # col1 = left aligned, col2 + col3 = center aligned +p.software_columns(text_list=text_list, widths=widths, align=align) + +# Tuning them all: +text_list = ["col1", "col2", "col3"] +widths = [5, 20, 15] +align = ["left", "center", "right"] +p.software_columns(text_list=text_list, widths=widths, align=align)