from .label_image import Label import qrcode class StorageLabel(Label): pixels_x = 991 pixels_y = 306 def __init__(self): super().__init__() def put_content(self, qr_data, storage_name): self.draw_text(storage_name, 320, self.pixels_y/2, size=32, font_file='bold', scale_to_fit=True, centered_x=False, centered_y=True) qr = qrcode.QRCode( version=1, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=8, 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)))