zprinter.py
def print_qr_with_text(self, text, quantity=1, scale=3, override_exit=False):
        """ Print a QR code with some text wrapped around it.

        !! This function is designed with the PCBA 2019 Serial Number !!
        !! in mind and is therefore not very practically implemented  !!
        !! for a more general application.                            !!

        Args:
            text: A string containing the data of interest.
            quantity: How many barcodes that should be consecutively
                      printer.
            scale: An integer to scale the size of the QR code.

        Returns:
            Nothing.

        Raises:
            Nothing.
        """
        binary_data, byte_string = create_binary_qr(text, scale)
        image = BinaryImage(binary_data)

        # Position the QR code to be centre top of the label
        qr_xpos, qr_ypos = self.align(image, x_align="centre", y_align="top")

        # Identify what size font to use based off the label length
        # by checking what will fit in the available space.
        erp_code = text[:11]
        for erp_font_size in reversed(range(1, 4)):
            objText_erp = Text(erp_code, font_size=erp_font_size)
            # If the text length is almost longer than the label width
            # Change the size of the font.
            if objText_erp.width_mm < self.label.width_mm - 2.0:
                break

        unique_id = text[11:]
        for uid_font_size in reversed(range(1, 4)):
            objText_uid = Text(unique_id, font_size=uid_font_size)
            # If the text length is almost longer than the label width
            # Change the size of the font.
            if objText_uid.width_mm < self.label.width_mm - 2.0:
                break

        # Define a gap between the QR code and the text as a proportion
        # of the text height. Each item is positioned below the item
        # above it.
        erp_xpos, _ = self.align(objText_erp, x_align="centre", y_align="top")
        uid_xpos, _ = self.align(objText_uid, x_align="centre", y_align="top")

        erp_ypos = (qr_ypos + image.length_dot) + int((4 - erp_font_size) * 0.2 * objText_erp.height_dot)
        uid_ypos =                     erp_ypos + int((4 - uid_font_size) * 0.2 * objText_uid.height_dot) + 15

        # Configure the printer
        for n in range(1, quantity + 1):
            self.commander.encode_binary_image(byte_string,
                                               width_dot=image.width_dot,
                                               length_dot=image.length_dot,
                                               start_x=qr_xpos, start_y=qr_ypos)

            self.commander.encode_text(objText_erp.text,
                                       start_x=erp_xpos, start_y=erp_ypos,
                                       font_size=objText_erp.font_size, invert=False)

            self.commander.encode_text(objText_uid.text,
                                       start_x=uid_xpos, start_y=uid_ypos,
                                       font_size=objText_uid.font_size, invert=False)

            self.commander.next_label()

        # If next_label has not been issued 'self.columns' times, then
        # force the printer to move to the next row.
        if not override_exit and n % self.columns != 0:
            self.commander.encode_print_label()
            self.commander.send_command()
 Print a QR code with some text wrapped around it.

        !! This function is designed with the PCBA 2019 Serial Number !!
        !! in mind and is therefore not very practically implemented  !!
        !! for a more general application.                            !!

        Args:
            text: A string containing the data of interest.
            quantity: How many barcodes that should be consecutively
                      printer.
            scale: An integer to scale the size of the QR code.

        Returns:
            Nothing.

        Raises:
            Nothing.
        
Print a QR code with some text wrapped around it.
This function is designed with the PCBA 2019 Serial Number
in mind and is therefore not very practically implemented
for a more general application.

A string containing the data of interest.
quantity: How many barcodes that should be consecutively
printer.
scale: An integer to scale the size of the QR code.

Nothing.

Nothing.
Print a QR code with some text wrapped around it . This function is designed with the PCBA 2019 Serial Number in mind and is therefore not very practically implemented for a more general application . A string containing the data of interest . quantity : How many barcodes that should be consecutively printer . scale : An integer to scale the size of the QR code . Nothing . Nothing .
def print_qr_with_text(self, text, quantity=1, scale=3, override_exit=False):
        binary_data, byte_string = create_binary_qr(text, scale)
        image = BinaryImage(binary_data)
        qr_xpos, qr_ypos = self.align(image, x_align="centre", y_align="top")
        erp_code = text[:11]
        for erp_font_size in reversed(range(1, 4)):
            objText_erp = Text(erp_code, font_size=erp_font_size)
            if objText_erp.width_mm < self.label.width_mm - 2.0:
                break
        unique_id = text[11:]
        for uid_font_size in reversed(range(1, 4)):
            objText_uid = Text(unique_id, font_size=uid_font_size)
            if objText_uid.width_mm < self.label.width_mm - 2.0:
                break
        erp_xpos, _ = self.align(objText_erp, x_align="centre", y_align="top")
        uid_xpos, _ = self.align(objText_uid, x_align="centre", y_align="top")
        erp_ypos = (qr_ypos + image.length_dot) + int((4 - erp_font_size) * 0.2 * objText_erp.height_dot)
        uid_ypos =                     erp_ypos + int((4 - uid_font_size) * 0.2 * objText_uid.height_dot) + 15
        for n in range(1, quantity + 1):
            self.commander.encode_binary_image(byte_string,
                                               width_dot=image.width_dot,
                                               length_dot=image.length_dot,
                                               start_x=qr_xpos, start_y=qr_ypos)
            self.commander.encode_text(objText_erp.text,
                                       start_x=erp_xpos, start_y=erp_ypos,
                                       font_size=objText_erp.font_size, invert=False)
            self.commander.encode_text(objText_uid.text,
                                       start_x=uid_xpos, start_y=uid_ypos,
                                       font_size=objText_uid.font_size, invert=False)
            self.commander.next_label()
        if not override_exit and n % self.columns != 0:
            self.commander.encode_print_label()
            self.commander.send_command()
def print_qr_with_text ( self , text , quantity = 1 , scale = 3 , override_exit = False ) : binary_data , byte_string = create_binary_qr ( text , scale ) image = BinaryImage ( binary_data ) qr_xpos , qr_ypos = self . align ( image , x_align = "centre" , y_align = "top" ) erp_code = text [ : 11 ] for erp_font_size in reversed ( range ( 1 , 4 ) ) : objText_erp = Text ( erp_code , font_size = erp_font_size ) if objText_erp . width_mm < self . label . width_mm - 2.0 : break unique_id = text [ 11 : ] for uid_font_size in reversed ( range ( 1 , 4 ) ) : objText_uid = Text ( unique_id , font_size = uid_font_size ) if objText_uid . width_mm < self . label . width_mm - 2.0 : break erp_xpos , _ = self . align ( objText_erp , x_align = "centre" , y_align = "top" ) uid_xpos , _ = self . align ( objText_uid , x_align = "centre" , y_align = "top" ) erp_ypos = ( qr_ypos + image . length_dot ) + int ( ( 4 - erp_font_size ) * 0.2 * objText_erp . height_dot ) uid_ypos = erp_ypos + int ( ( 4 - uid_font_size ) * 0.2 * objText_uid . height_dot ) + 15 for n in range ( 1 , quantity + 1 ) : self . commander . encode_binary_image ( byte_string , width_dot = image . width_dot , length_dot = image . length_dot , start_x = qr_xpos , start_y = qr_ypos ) self . commander . encode_text ( objText_erp . text , start_x = erp_xpos , start_y = erp_ypos , font_size = objText_erp . font_size , invert = False ) self . commander . encode_text ( objText_uid . text , start_x = uid_xpos , start_y = uid_ypos , font_size = objText_uid . font_size , invert = False ) self . commander . next_label ( ) if not override_exit and n % self . columns != 0 : self . commander . encode_print_label ( ) self . commander . send_command ( )
Print a QR code with some text wrapped around it.
Print a QR code with some text wrapped around it .
""" Print a QR code with some text wrapped around it.

        !! This function is designed with the PCBA 2019 Serial Number !!
        !! in mind and is therefore not very practically implemented  !!
        !! for a more general application.                            !!

        Args:
            text: A string containing the data of interest.
            quantity: How many barcodes that should be consecutively
                      printer.
            scale: An integer to scale the size of the QR code.

        Returns:
            Nothing.

        Raises:
            Nothing.
        """ # Position the QR code to be centre top of the label # Identify what size font to use based off the label length # by checking what will fit in the available space. # If the text length is almost longer than the label width # Change the size of the font. # If the text length is almost longer than the label width # Change the size of the font. # Define a gap between the QR code and the text as a proportion # of the text height. Each item is positioned below the item # above it. # Configure the printer # If next_label has not been issued 'self.columns' times, then # force the printer to move to the next row.
self
text
quantity
scale
override_exit