zprinter.py
def align(self, obj, x_align, y_align):
        """
        Return alignment locations (in dot position) for the given
        object.

        Args:
            obj <obj>: An printable object instance, such as Text()
                Barcode(), BinaryImage(), e.t.c.
            x_align <str>/<int>: "L"eft, "C"entre, "R"ight, or an
                integer representing in dots where the object should be
                printed from.
            y_align <str>/<int>: "T"op, "M"iddle, "B"ottom, or an
                integer representing in dots where the object should be
                printed from.

        Returns:
            Returns two integers for x_pos and y_pos. If there is an
            error, the returned co-ordinates will be (0, 0) which is
            the same as top-left positioning.
        """
        if type(x_align) == str:
            x_align = x_align.upper()
            if x_align == "C" or x_align == "CENTRE":
                x_pos_dot = int((self.label.width_dot - obj.width_dot) / 2.0)
            elif x_align == "R" or x_align == "RIGHT":
                x_pos_dot = int(self.label.width_dot - obj.width_dot)
            elif x_align == "L" or x_align == "LEFT":
                x_pos_dot = int(0)
            else:
                print("WARN: Incorrect x-alignment input. Left alignment returned.")
                x_pos_dot = int(0)

        elif type(x_align) == int:
            xpos_dot = int(x_align)

        else:
            print("WARN: Incorrect x-alignment input. Left alignment returned.")
            x_pos_dot = int(0)

        if type(y_align) == str:
            # For nicer interpretation, some objects use 'height' or some
            # objects use 'length' to represent y-direction dimensions.
            try:
                ydim = obj.length_dot
            except AttributeError:
                # AttributeError: 'X' object has no attribute 'length_dot'
                ydim = obj.height_dot

            y_align = y_align.upper()
            if y_align == "M" or y_align == "MID" or y_align == "MIDDLE":
                y_pos_dot = int((self.label.length_dot - ydim) / 2.0)
            elif y_align == "B" or y_align == "BOT" or y_align == "BOTTOM":
                y_pos_dot = int(self.label.length_dot - ydim)
            elif y_align == "T" or y_align == "TOP":
                y_pos_dot = int(0)
            else:
                print("WARN: Incorrect y-alignment input. Top alignment returned.")
                y_pos_dot = int(0)

        elif type(y_align) == int:
            ypos_dot = int(y_align)

        else:
            print("WARN: Incorrect y-alignment input. Top alignment returned.")
            ypos_dot = int(0)

        return(x_pos_dot, y_pos_dot)

        Return alignment locations (in dot position) for the given
        object.

        Args:
            obj <obj>: An printable object instance, such as Text()
                Barcode(), BinaryImage(), e.t.c.
            x_align <str>/<int>: "L"eft, "C"entre, "R"ight, or an
                integer representing in dots where the object should be
                printed from.
            y_align <str>/<int>: "T"op, "M"iddle, "B"ottom, or an
                integer representing in dots where the object should be
                printed from.

        Returns:
            Returns two integers for x_pos and y_pos. If there is an
            error, the returned co-ordinates will be (0, 0) which is
            the same as top-left positioning.
        
Return alignment locations (in dot position) for the given
object.
Return alignment locations ( in dot position ) for the given object .
def align(self, obj, x_align, y_align):
        if type(x_align) == str:
            x_align = x_align.upper()
            if x_align == "C" or x_align == "CENTRE":
                x_pos_dot = int((self.label.width_dot - obj.width_dot) / 2.0)
            elif x_align == "R" or x_align == "RIGHT":
                x_pos_dot = int(self.label.width_dot - obj.width_dot)
            elif x_align == "L" or x_align == "LEFT":
                x_pos_dot = int(0)
            else:
                print("WARN: Incorrect x-alignment input. Left alignment returned.")
                x_pos_dot = int(0)
        elif type(x_align) == int:
            xpos_dot = int(x_align)
        else:
            print("WARN: Incorrect x-alignment input. Left alignment returned.")
            x_pos_dot = int(0)
        if type(y_align) == str:
            try:
                ydim = obj.length_dot
            except AttributeError:
                ydim = obj.height_dot
            y_align = y_align.upper()
            if y_align == "M" or y_align == "MID" or y_align == "MIDDLE":
                y_pos_dot = int((self.label.length_dot - ydim) / 2.0)
            elif y_align == "B" or y_align == "BOT" or y_align == "BOTTOM":
                y_pos_dot = int(self.label.length_dot - ydim)
            elif y_align == "T" or y_align == "TOP":
                y_pos_dot = int(0)
            else:
                print("WARN: Incorrect y-alignment input. Top alignment returned.")
                y_pos_dot = int(0)
        elif type(y_align) == int:
            ypos_dot = int(y_align)
        else:
            print("WARN: Incorrect y-alignment input. Top alignment returned.")
            ypos_dot = int(0)
        return(x_pos_dot, y_pos_dot)
def align ( self , obj , x_align , y_align ) : if type ( x_align ) == str : x_align = x_align . upper ( ) if x_align == "C" or x_align == "CENTRE" : x_pos_dot = int ( ( self . label . width_dot - obj . width_dot ) / 2.0 ) elif x_align == "R" or x_align == "RIGHT" : x_pos_dot = int ( self . label . width_dot - obj . width_dot ) elif x_align == "L" or x_align == "LEFT" : x_pos_dot = int ( 0 ) else : print ( "WARN: Incorrect x-alignment input. Left alignment returned." ) x_pos_dot = int ( 0 ) elif type ( x_align ) == int : xpos_dot = int ( x_align ) else : print ( "WARN: Incorrect x-alignment input. Left alignment returned." ) x_pos_dot = int ( 0 ) if type ( y_align ) == str : try : ydim = obj . length_dot except AttributeError : ydim = obj . height_dot y_align = y_align . upper ( ) if y_align == "M" or y_align == "MID" or y_align == "MIDDLE" : y_pos_dot = int ( ( self . label . length_dot - ydim ) / 2.0 ) elif y_align == "B" or y_align == "BOT" or y_align == "BOTTOM" : y_pos_dot = int ( self . label . length_dot - ydim ) elif y_align == "T" or y_align == "TOP" : y_pos_dot = int ( 0 ) else : print ( "WARN: Incorrect y-alignment input. Top alignment returned." ) y_pos_dot = int ( 0 ) elif type ( y_align ) == int : ypos_dot = int ( y_align ) else : print ( "WARN: Incorrect y-alignment input. Top alignment returned." ) ypos_dot = int ( 0 ) return ( x_pos_dot , y_pos_dot )
Return alignment locations (in dot position) for the given
object.
Return alignment locations ( in dot position ) for the given object .
"""
        Return alignment locations (in dot position) for the given
        object.

        Args:
            obj <obj>: An printable object instance, such as Text()
                Barcode(), BinaryImage(), e.t.c.
            x_align <str>/<int>: "L"eft, "C"entre, "R"ight, or an
                integer representing in dots where the object should be
                printed from.
            y_align <str>/<int>: "T"op, "M"iddle, "B"ottom, or an
                integer representing in dots where the object should be
                printed from.

        Returns:
            Returns two integers for x_pos and y_pos. If there is an
            error, the returned co-ordinates will be (0, 0) which is
            the same as top-left positioning.
        """ # For nicer interpretation, some objects use 'height' or some # objects use 'length' to represent y-direction dimensions. # AttributeError: 'X' object has no attribute 'length_dot'
Returns two integers for x_pos and y_pos. If there is an
error, the returned co-ordinates will be (0, 0) which is
the same as top-left positioning.
Returns two integers for x_pos and y_pos . If there is an error the returned co - ordinates will be ( 0 0 ) which is the same as top - left positioning .
self
obj
x_align
y_align
obj <obj>
An printable object instance, such as Text()
Barcode(), BinaryImage(), e.t.c.
An printable object instance such as Text () Barcode () BinaryImage () e . t . c .
x_align <str>/<int>
"L"eft, "C"entre, "R"ight, or an
integer representing in dots where the object should be
printed from.
" L " eft " C " entre " R " ight or an integer representing in dots where the object should be printed from .
y_align <str>/<int>
"T"op, "M"iddle, "B"ottom, or an
integer representing in dots where the object should be
printed from.
" T " op " M " iddle " B " ottom or an integer representing in dots where the object should be printed from .