123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- from .label_image import Label
- import qrcode
- class StorageLabel(Label):
- pixels_x = 696
- pixels_y = 250
- text_pos_x = 225
- qr_size = 9
- text_size_verbose_name = 48
- text_size_name = 32
- ql_format = '62'
- ql_rotation = 0
- dpi_600 = False
- red_label = True
- def __init__(self):
- super().__init__()
- def put_content(self, qr_data, storage_name, verbose_name=None):
- name_pos = self.pixels_y/2
- name_font_file = 'bold'
- if verbose_name:
- self.draw_text(verbose_name,
- self.text_pos_x,
- self.pixels_y/4,
- size=self.text_size_verbose_name,
- font_file='bold',
- scale_to_fit=True,
- centered_x=False,
- centered_y=True)
- name_pos = self.pixels_y/4 * 3
- name_font_file = None
- self.draw_text(storage_name,
- self.text_pos_x,
- name_pos,
- size=self.text_size_name,
- font_file=name_font_file,
- scale_to_fit=True,
- centered_x=False,
- centered_y=True)
- qr = qrcode.QRCode(
- version=1,
- error_correction=qrcode.constants.ERROR_CORRECT_L,
- box_size=7,
- border=0,
- )
- qr.add_data(qr_data)
- qr.make(fit=True)
- qr_image = qr.make_image(fill_color="black", back_color="white")
- qr_y_size = qr_image.size[1]
- self.img.paste(qr_image, box=(0, int(self.pixels_y/2 - qr_y_size/2)))
- class StorageLabelSmdMiceToilet(StorageLabel):
- pixels_x = 1108
- pixels_y = 200
- qr_size = 7
- text_size_verbose_name = 64
- text_size_name = 48
- text_pos_x = 320
- ql_format = '50'
- ql_rotation = 0
- dpi_600 = True
- red_label = False
- class StorageLabelSmdMiceToiletBottomQR(StorageLabel):
- pixels_x = 307
- pixels_y = 212
- ql_format = '12'
- ql_rotation = 270
- dpi_600 = True
- red_label = False
- def put_content(self, qr_data, storage_name=None, verbose_name=None):
- qr = qrcode.QRCode(
- version=1,
- error_correction=qrcode.constants.ERROR_CORRECT_L,
- box_size=7,
- border=0,
- )
- qr.add_data(qr_data)
- qr.make(fit=True)
- qr_image = qr.make_image(fill_color="black", back_color="white")
- qr_x_size = qr_image.size[0]
- qr_y_size = qr_image.size[1]
- self.img.paste(qr_image, box=(int(self.pixels_x/2 - qr_x_size/2), int(self.pixels_y/2 - qr_y_size/2)))
|