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 StorageLabelSmdStrap(StorageLabel): pixels_x = 700 pixels_y = 212 qr_size = 7 text_size_verbose_name = 64 text_size_name = 64 text_pos_x = 250 ql_format = '12' ql_rotation = 270 dpi_600 = True red_label = False 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))) class StorageLabelSmdMiceToiletTop(StorageLabel): pixels_x = 307 pixels_y = 212 ql_format = '12' ql_rotation = 270 dpi_600 = True red_label = False def put_content(self, heading, line_1=None, line_2=None): self.draw_text(heading, self.pixels_x/2, 40, size=50, font_file='bold', centered_x=True, centered_y=True, scale_to_fit=True) if line_1: self.draw_text(line_1, self.pixels_x/2, 110, size=40, centered_x=True, centered_y=True, scale_to_fit=True) if line_2: self.draw_text(line_2, self.pixels_x/2, 170, size=40, centered_x=True, centered_y=True, scale_to_fit=True)