Beispiel #1
0
 def __init__(self, prefix="", number=None, subtype="1", border=None, checksum=False, availheight=None):
     """
        Initializes an LTO label.
     
        prefix : Up to six characters from [A-Z][0-9]. Defaults to "".
        number : Label's number or None. Defaults to None.
        subtype : LTO subtype string , e.g. "1" for LTO1. Defaults to "1".
        border : None, or the width of the label's border. Defaults to None.
        checksum : Boolean indicates if checksum char has to be printed. Defaults to False.
        availheight : Available height on the label, or None for automatic. Defaults to None.
     """
     self.height = max(availheight, self.CODEBARHEIGHT)
     self.border = border
     if (len(subtype) != 1) or (subtype not in string.ascii_uppercase + string.digits):
         raise ValueError, "Invalid subtype '%s'" % subtype
     if ((not number) and (len(prefix) > 6)) or not prefix.isalnum():
         raise ValueError, "Invalid prefix '%s'" % prefix
     label = "%sL%s" % ((prefix + str(number or 0).zfill(6 - len(prefix)))[:6], subtype)
     if len(label) != 8:
         raise ValueError, "Invalid set of parameters (%s, %s, %s)" % (prefix, number, subtype)
     self.label = label
     Standard39.__init__(
         self,
         label,
         ratio=self.CODERATIO,
         barHeight=self.height,
         barWidth=self.CODEBARWIDTH,
         gap=self.CODEGAP,
         lquiet=self.CODELQUIET,
         rquiet=self.CODERQUIET,
         quiet=True,
         checksum=checksum,
     )
Beispiel #2
0
 def drawOn(self, canvas, x, y):
     """Draws the LTO label onto the canvas."""
     canvas.saveState()
     canvas.translate(x, y)
     if self.border:
         canvas.setLineWidth(self.border)
         canvas.roundRect(0, 0, self.LABELWIDTH, self.LABELHEIGHT, self.LABELROUND)
     Standard39.drawOn(self, canvas, (self.LABELWIDTH - self.CODENOMINALWIDTH) / 2.0, self.LABELHEIGHT - self.height)
     canvas.restoreState()
Beispiel #3
0
 def drawOn(self, canvas, x, y):
     """Draws the LTO label onto the canvas."""
     canvas.saveState()
     canvas.translate(x, y)
     if self.border:
         canvas.setLineWidth(self.border)
         canvas.roundRect(0, 0, self.LABELWIDTH, self.LABELHEIGHT,
                          self.LABELROUND)
     Standard39.drawOn(self, canvas,
                       (self.LABELWIDTH - self.CODENOMINALWIDTH) / 2.0,
                       self.LABELHEIGHT - self.height)
     canvas.restoreState()
Beispiel #4
0
    def __init__(self,
                 prefix="",
                 number=None,
                 subtype="1",
                 border=None,
                 checksum=False,
                 availheight=None):
        """
           Initializes an LTO label.

           prefix : Up to six characters from [A-Z][0-9]. Defaults to "".
           number : Label's number or None. Defaults to None.
           subtype : LTO subtype string , e.g. "1" for LTO1. Defaults to "1".
           border : None, or the width of the label's border. Defaults to None.
           checksum : Boolean indicates if checksum char has to be printed. Defaults to False.
           availheight : Available height on the label, or None for automatic. Defaults to None.
        """
        self.height = max(availheight, self.CODEBARHEIGHT)
        self.border = border
        if (len(subtype) != 1) \
            or (subtype not in string.ascii_uppercase + string.digits) :
            raise ValueError, "Invalid subtype '%s'" % subtype
        if ((not number) and (len(prefix) > 6)) \
           or not prefix.isalnum() :
            raise ValueError, "Invalid prefix '%s'" % prefix
        label = "%sL%s" % (
            (prefix + str(number or 0).zfill(6 - len(prefix)))[:6], subtype)
        if len(label) != 8:
            raise ValueError, "Invalid set of parameters (%s, %s, %s)" \
                                % (prefix, number, subtype)
        self.label = label
        Standard39.__init__(self,
                            label,
                            ratio=self.CODERATIO,
                            barHeight=self.height,
                            barWidth=self.CODEBARWIDTH,
                            gap=self.CODEGAP,
                            lquiet=self.CODELQUIET,
                            rquiet=self.CODERQUIET,
                            quiet=True,
                            checksum=checksum)