123456789101112131415161718192021222324252627282930313233 |
- #!/bin/python
- import shimatta_label.label_image as li
- import shimatta_label.brother_ql_wrapper as ql_wrapper
- import sys
- import treepoem
- class DotmatrixLabel(li.Label):
- pixels_x = 120
- pixels_y = 106
- def put_matrix_code(self, qr):
- code = treepoem.generate_barcode('datamatrix', qr).convert('1')
- box = (int(self.pixels_x/2 -code.size[0]/2), int(self.pixels_y/2 - code.size[1]/2))
- self.img.paste(code, box=box)
- printer_model = 'QL-800'
- printer_connection = 'usb://0x04f9:0x209b'
- if len(sys.argv) >= 2:
- qr_data = sys.argv[1]
- else:
- qr_data = input('Scan QR Code: ')
- while qr_data:
- label = DotmatrixLabel()
- label.put_matrix_code(qr_data)
- #label.save('/tmp/foo.png')
- printer = ql_wrapper.BrotherQlPrinter(model=printer_model, printer_connection=printer_connection, label_format='12')
- printer.print_image(label.get_pillow_image(), cut=True, rotation=90)
- qr_data = input('Scan QR Code: ')
|