micetoilet-labelgen/print_labels_from_csv.py

27 lines
765 B
Python
Raw Normal View History

2021-12-30 16:12:24 +01:00
#!/bin/python
2021-12-27 20:52:01 +01:00
import pandas as pd
import shimatta_label.label_image as li
import shimatta_label.brother_ql_wrapper as ql_wrapper
import os
import sys
2021-12-27 20:52:01 +01:00
medir = os.path.dirname(__file__)
2021-12-27 23:30:21 +01:00
if len(sys.argv) > 1:
example_data_path = sys.argv[1]
else:
example_data_path = os.path.join(medir, 'labels.csv')
2021-12-27 20:52:01 +01:00
df = pd.read_csv(example_data_path, converters={i: str for i in range(3)})
2021-12-27 20:52:01 +01:00
2021-12-28 18:13:36 +01:00
printer = ql_wrapper.BrotherQlPrinter(model='QL-800', printer_connection='usb://0x04f9:0x209b', label_format='12')
2021-12-27 20:52:01 +01:00
for _, row in df.iterrows():
label = li.MiceToiletLabel()
label.put_text(row['Heading'], row['Line1'], row['Line2'])
cut = False
if row['Cut'] == 1:
cut = True
2021-12-28 18:13:36 +01:00
printer.print_image(label.get_pillow_image(), cut = cut, rotation=270)