zprinter.py
def print_barcode(self, text, quantity=1, bc_height_mm=None, invert=False, override_exit=False):
        """ Print a barcode with some text below it.

        Args:
            text: The string the barcode and text should display.
            quantity: How many barcodes that should be consecutively
                printer.
            invert: Set to True to display the text as white on a black
                background. Set to False to display the text as normal.
            override_exit: Set to True to stop the printer processing a
                row. This is necessary if there are multiple labels per
                row.
            bc_height_mm: Define how tall the barcode portion of the
                label should be.

        Returns:
            Nothing.

        Raises:
            Nothing.
        """
        # Determine a height for the barcode if none is given.
        if bc_height_mm is None:
            bc_height_mm = self.label.height_mm / 2.0

        # Create the Barcode object. The barcode object may crop the
        # text if it is too long to fit on the label. Therefore, the
        # string may be shorted.
        objBarcode = Barcode(text, height_mm=bc_height_mm, max_width_mm=self.label.width_mm)
        barcode_text = objBarcode.text

        # Align the barcode to top-centre.
        bc_xpos, bc_ypos = self.align(objBarcode, x_align="centre", y_align="top")

        # Identify what font size to use by checking what will fit in
        # the available width.
        for font_size in reversed(range(1, 4)):
            objText = Text(barcode_text, font_size=font_size)
            # If the text length is almost longer than the label width
            # change the size of the font.
            if objText.width_mm < self.label.width_mm - 2.0:
                break
            else:
                print("WARN: Text '{}' will not fit on the label".format(barcode_text))

        # Align the text to be central below the barcode. Define the
        # gap between the barcode and the text as a proportion of the
        # text height.
        text_xpos, _ = self.align(objText, x_align="centre", y_align="top")
        text_ypos    = objBarcode.height_dot + int((4 - font_size) * 0.2 * objText.height_dot)

        # Submit the print command.
        for n in range(1, quantity + 1):
            self.commander.encode_barcode_c128(objBarcode.text, start_x=bc_xpos, start_y=bc_ypos,
                                               height_dot=objBarcode.height_dot)

            self.commander.encode_text(objText.text, start_x=text_xpos, start_y=text_ypos,
                                       font_size=objText.font_size, invert=invert)

            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 barcode with some text below it.

        Args:
            text: The string the barcode and text should display.
            quantity: How many barcodes that should be consecutively
                printer.
            invert: Set to True to display the text as white on a black
                background. Set to False to display the text as normal.
            override_exit: Set to True to stop the printer processing a
                row. This is necessary if there are multiple labels per
                row.
            bc_height_mm: Define how tall the barcode portion of the
                label should be.

        Returns:
            Nothing.

        Raises:
            Nothing.
        
Print a barcode with some text below it.
Args:
text: The string the barcode and text should display.
quantity: How many barcodes that should be consecutively
printer.
invert: Set to True to display the text as white on a black
background. Set to False to display the text as normal.
override_exit: Set to True to stop the printer processing a
row. This is necessary if there are multiple labels per
row.
bc_height_mm: Define how tall the barcode portion of the
label should be.

Nothing.

Nothing.
Print a barcode with some text below it . Args : text : The string the barcode and text should display . quantity : How many barcodes that should be consecutively printer . invert : Set to True to display the text as white on a black background . Set to False to display the text as normal . override_exit : Set to True to stop the printer processing a row . This is necessary if there are multiple labels per row . bc_height_mm : Define how tall the barcode portion of the label should be . Nothing . Nothing .
def print_barcode(self, text, quantity=1, bc_height_mm=None, invert=False, override_exit=False):
        if bc_height_mm is None:
            bc_height_mm = self.label.height_mm / 2.0
        objBarcode = Barcode(text, height_mm=bc_height_mm, max_width_mm=self.label.width_mm)
        barcode_text = objBarcode.text
        bc_xpos, bc_ypos = self.align(objBarcode, x_align="centre", y_align="top")
        for font_size in reversed(range(1, 4)):
            objText = Text(barcode_text, font_size=font_size)
            if objText.width_mm < self.label.width_mm - 2.0:
                break
            else:
                print("WARN: Text '{}' will not fit on the label".format(barcode_text))
        text_xpos, _ = self.align(objText, x_align="centre", y_align="top")
        text_ypos    = objBarcode.height_dot + int((4 - font_size) * 0.2 * objText.height_dot)
        for n in range(1, quantity + 1):
            self.commander.encode_barcode_c128(objBarcode.text, start_x=bc_xpos, start_y=bc_ypos,
                                               height_dot=objBarcode.height_dot)
            self.commander.encode_text(objText.text, start_x=text_xpos, start_y=text_ypos,
                                       font_size=objText.font_size, invert=invert)
            self.commander.next_label()
        if not override_exit and n % self.columns != 0:
            self.commander.encode_print_label()
            self.commander.send_command()
def print_barcode ( self , text , quantity = 1 , bc_height_mm = None , invert = False , override_exit = False ) : if bc_height_mm is None : bc_height_mm = self . label . height_mm / 2.0 objBarcode = Barcode ( text , height_mm = bc_height_mm , max_width_mm = self . label . width_mm ) barcode_text = objBarcode . text bc_xpos , bc_ypos = self . align ( objBarcode , x_align = "centre" , y_align = "top" ) for font_size in reversed ( range ( 1 , 4 ) ) : objText = Text ( barcode_text , font_size = font_size ) if objText . width_mm < self . label . width_mm - 2.0 : break else : print ( "WARN: Text '{}' will not fit on the label" . format ( barcode_text ) ) text_xpos , _ = self . align ( objText , x_align = "centre" , y_align = "top" ) text_ypos = objBarcode . height_dot + int ( ( 4 - font_size ) * 0.2 * objText . height_dot ) for n in range ( 1 , quantity + 1 ) : self . commander . encode_barcode_c128 ( objBarcode . text , start_x = bc_xpos , start_y = bc_ypos , height_dot = objBarcode . height_dot ) self . commander . encode_text ( objText . text , start_x = text_xpos , start_y = text_ypos , font_size = objText . font_size , invert = invert ) self . commander . next_label ( ) if not override_exit and n % self . columns != 0 : self . commander . encode_print_label ( ) self . commander . send_command ( )
Print a barcode with some text below it.
Print a barcode with some text below it .
""" Print a barcode with some text below it.

        Args:
            text: The string the barcode and text should display.
            quantity: How many barcodes that should be consecutively
                printer.
            invert: Set to True to display the text as white on a black
                background. Set to False to display the text as normal.
            override_exit: Set to True to stop the printer processing a
                row. This is necessary if there are multiple labels per
                row.
            bc_height_mm: Define how tall the barcode portion of the
                label should be.

        Returns:
            Nothing.

        Raises:
            Nothing.
        """ # Determine a height for the barcode if none is given. # Create the Barcode object. The barcode object may crop the # text if it is too long to fit on the label. Therefore, the # string may be shorted. # Align the barcode to top-centre. # Identify what font size to use by checking what will fit in # the available width. # If the text length is almost longer than the label width # change the size of the font. # Align the text to be central below the barcode. Define the # gap between the barcode and the text as a proportion of the # text height. # Submit the print command. # If next_label has not been issued 'self.columns' times, then # force the printer to move to the next row.
self
text
quantity
bc_height_mm
invert
override_exit