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) > 2: 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') 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)