micetoilet-labelgen/print_labels_from_csv.py

27 lines
765 B
Python
Executable File

#!/bin/python
import pandas as pd
import shimatta_label.label_image as li
import shimatta_label.brother_ql_wrapper as ql_wrapper
import os
import sys
medir = os.path.dirname(__file__)
if len(sys.argv) > 1:
example_data_path = sys.argv[1]
else:
example_data_path = os.path.join(medir, 'labels.csv')
df = pd.read_csv(example_data_path, converters={i: str for i in range(3)})
printer = ql_wrapper.BrotherQlPrinter(model='QL-800', printer_connection='usb://0x04f9:0x209b', label_format='12')
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
printer.print_image(label.get_pillow_image(), cut = cut, rotation=270)