print_labels_from_csv.py 765 B

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