micetoilet-labelgen/print_labels_from_csv.py

26 lines
769 B
Python
Raw Normal View History

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__)
if len(sys.argv) > 2:
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
printer = ql_wrapper.BrotherQlPrinter(model='QL-800', printer_connection='usb://0x04f9:0x209b')
for _, row in df.iterrows():
label = li.MiceToiletLabel()
label.put_text(row['Heading'], row['Line1'], row['Line2'])
file_path = label.save()
cut = False
if row['Cut'] == 1:
cut = True
printer.print_image(file_path, cut = cut, rotation=270)
os.remove(file_path)