print_labels_from_csv.py 750 B

123456789101112131415161718192021222324
  1. import pandas as pd
  2. import shimatta_label.label_image as li
  3. import shimatta_label.brother_ql_wrapper as ql_wrapper
  4. import os
  5. import sys
  6. medir = os.path.dirname(__file__)
  7. if len(sys.argv) > 1:
  8. example_data_path = sys.argv[1]
  9. else:
  10. example_data_path = os.path.join(medir, 'labels.csv')
  11. df = pd.read_csv(example_data_path, converters={i: str for i in range(3)})
  12. printer = ql_wrapper.BrotherQlPrinter(model='QL-800', printer_connection='usb://0x04f9:0x209b', label_format='12')
  13. for _, row in df.iterrows():
  14. label = li.MiceToiletLabel()
  15. label.put_text(row['Heading'], row['Line1'], row['Line2'])
  16. cut = False
  17. if row['Cut'] == 1:
  18. cut = True
  19. printer.print_image(label.get_pillow_image(), cut = cut, rotation=270)