bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): #print "cellstyle is ", repr(cellstyle), id(cellstyle) if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: #print "setting cell color to %s" % `cellstyle.color` self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontname or cellstyle.fontsize != cur.fontsize: #print "setting font: %s, %s, %s" % (cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self.canv.setFont(cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self._curcellstyle = cellstyle #print "leading is ", cellstyle.leading, "size is", cellstyle.fontsize just = cellstyle.alignment #print "alignment is ", just if just == 'LEFT': draw = self.canv.drawString x = colpos + cellstyle.leftPadding elif just in ('CENTRE', 'CENTER'): draw = self.canv.drawCentredString x = colpos + colwidth * 0.5 elif just == 'RIGHT': draw = self.canv.drawRightString x = colpos + colwidth - cellstyle.rightPadding else: raise ValueError, 'Invalid justification %s' % just
def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): #print "cellstyle is ", repr(cellstyle), id(cellstyle) if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: #print "setting cell color to %s" % `cellstyle.color` self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontname or cellstyle.fontsize != cur.fontsize: #print "setting font: %s, %s, %s" % (cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self.canv.setFont(cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self._curcellstyle = cellstyle #print "leading is ", cellstyle.leading, "size is", cellstyle.fontsize just = cellstyle.alignment #print "alignment is ", just if just == 'LEFT': draw = self.canv.drawString x = colpos + cellstyle.leftPadding elif just in ('CENTRE', 'CENTER'): draw = self.canv.drawCentredString x = colpos + colwidth * 0.5 elif just == 'RIGHT': draw = self.canv.drawRightString x = colpos + colwidth - cellstyle.rightPadding else: raise ValueError, 'Invalid justification %s' % just
5,000
def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): #print "cellstyle is ", repr(cellstyle), id(cellstyle) if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: #print "setting cell color to %s" % `cellstyle.color` self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontname or cellstyle.fontsize != cur.fontsize: #print "setting font: %s, %s, %s" % (cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self.canv.setFont(cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self._curcellstyle = cellstyle #print "leading is ", cellstyle.leading, "size is", cellstyle.fontsize just = cellstyle.alignment #print "alignment is ", just if just == 'LEFT': draw = self.canv.drawString x = colpos + cellstyle.leftPadding elif just in ('CENTRE', 'CENTER'): draw = self.canv.drawCentredString x = colpos + colwidth * 0.5 elif just == 'RIGHT': draw = self.canv.drawRightString x = colpos + colwidth - cellstyle.rightPadding else: raise ValueError, 'Invalid justification %s' % just
def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): #print "cellstyle is ", repr(cellstyle), id(cellstyle) if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: #print "setting cell color to %s" % `cellstyle.color` self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontname or cellstyle.fontsize != cur.fontsize: #print "setting font: %s, %s, %s" % (cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self.canv.setFont(cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self._curcellstyle = cellstyle #print "leading is ", cellstyle.leading, "size is", cellstyle.fontsize just = cellstyle.alignment #print "alignment is ", just if just == 'LEFT': draw = self.canv.drawString x = colpos + cellstyle.leftPadding elif just in ('CENTRE', 'CENTER'): draw = self.canv.drawCentredString x = colpos + colwidth * 0.5 elif just == 'RIGHT': draw = self.canv.drawRightString x = colpos + colwidth - cellstyle.rightPadding else: raise ValueError, 'Invalid justification %s' % just
5,001
def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): #print "cellstyle is ", repr(cellstyle), id(cellstyle) if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: #print "setting cell color to %s" % `cellstyle.color` self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontname or cellstyle.fontsize != cur.fontsize: #print "setting font: %s, %s, %s" % (cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self.canv.setFont(cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self._curcellstyle = cellstyle #print "leading is ", cellstyle.leading, "size is", cellstyle.fontsize just = cellstyle.alignment #print "alignment is ", just if just == 'LEFT': draw = self.canv.drawString x = colpos + cellstyle.leftPadding elif just in ('CENTRE', 'CENTER'): draw = self.canv.drawCentredString x = colpos + colwidth * 0.5 elif just == 'RIGHT': draw = self.canv.drawRightString x = colpos + colwidth - cellstyle.rightPadding else: raise ValueError, 'Invalid justification %s' % just
def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): #print "cellstyle is ", repr(cellstyle), id(cellstyle) if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: #print "setting cell color to %s" % `cellstyle.color` self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontname or cellstyle.fontsize != cur.fontsize: #print "setting font: %s, %s, %s" % (cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self.canv.setFont(cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self._curcellstyle = cellstyle #print "leading is ", cellstyle.leading, "size is", cellstyle.fontsize just = cellstyle.alignment #print "alignment is ", just if just == 'LEFT': draw = self.canv.drawString x = colpos + cellstyle.leftPadding elif just in ('CENTRE', 'CENTER'): draw = self.canv.drawCentredString x = colpos + colwidth * 0.5 elif just == 'RIGHT': draw = self.canv.drawRightString x = colpos + colwidth - cellstyle.rightPadding else: raise ValueError, 'Invalid justification %s' % just
5,002
def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): #print "cellstyle is ", repr(cellstyle), id(cellstyle) if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: #print "setting cell color to %s" % `cellstyle.color` self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontname or cellstyle.fontsize != cur.fontsize: #print "setting font: %s, %s, %s" % (cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self.canv.setFont(cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self._curcellstyle = cellstyle #print "leading is ", cellstyle.leading, "size is", cellstyle.fontsize just = cellstyle.alignment #print "alignment is ", just if just == 'LEFT': draw = self.canv.drawString x = colpos + cellstyle.leftPadding elif just in ('CENTRE', 'CENTER'): draw = self.canv.drawCentredString x = colpos + colwidth * 0.5 elif just == 'RIGHT': draw = self.canv.drawRightString x = colpos + colwidth - cellstyle.rightPadding else: raise ValueError, 'Invalid justification %s' % just
def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)): #print "cellstyle is ", repr(cellstyle), id(cellstyle) if self._curcellstyle is not cellstyle: cur = self._curcellstyle if cur is None or cellstyle.color != cur.color: #print "setting cell color to %s" % `cellstyle.color` self.canv.setFillColor(cellstyle.color) if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontname or cellstyle.fontsize != cur.fontsize: #print "setting font: %s, %s, %s" % (cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self.canv.setFont(cellstyle.fontname, cellstyle.fontsize, cellstyle.leading) self._curcellstyle = cellstyle #print "leading is ", cellstyle.leading, "size is", cellstyle.fontsize just = cellstyle.alignment #print "alignment is ", just if just == 'LEFT': draw = self.canv.drawString x = colpos + cellstyle.leftPadding elif just in ('CENTRE', 'CENTER'): draw = self.canv.drawCentredString x = colpos + colwidth * 0.5 elif just == 'RIGHT': draw = self.canv.drawRightString x = colpos + colwidth - cellstyle.rightPadding else: raise ValueError, 'Invalid justification %s' % just
5,003
def _setCellStyle(cellStyles, i, j, op, values): new = CellStyle('<%d, %d>' % (i,j), cellStyles[i][j]) cellStyles[i][j] = new if op == 'FONT': new.fontname = values[0] new.fontsize = values[1] elif op == 'TEXTCOLOR': new.color = colors.toColor(values[0], colors.Color(0,0,0)) elif op in ('ALIGN', 'ALIGNMENT'): new.alignment = values[0] elif op == 'VALIGN': new.valign = values[0] elif op == 'LEFTPADDING': new.leftPadding = values[0] elif op == 'RIGHTPADDING': new.rightPadding = values[0] elif op == 'TOPPADDING': new.topPadding = values[0] elif op == 'BOTTOMPADDING': new.bottomPadding = values[0]
def _setCellStyle(cellStyles, i, j, op, values): new = CellStyle('<%d, %d>' % (i,j), cellStyles[i][j]) cellStyles[i][j] = new if op == 'FONT': new.fontname = values[0] if n>1: new.fontsize = values[1] if n>2: new.leading = values[2] elif op in ('FONTNAME', 'FACE'): new.fontname = values[0] elif op in ('SIZE', 'FONTSIZE'): new.fontsize = values[0] elif op == 'LEADING': new.leading = values[0] elif op == 'TEXTCOLOR': new.color = colors.toColor(values[0], colors.Color(0,0,0)) elif op in ('ALIGN', 'ALIGNMENT'): new.alignment = values[0] elif op == 'VALIGN': new.valign = values[0] elif op == 'LEFTPADDING': new.leftPadding = values[0] elif op == 'RIGHTPADDING': new.rightPadding = values[0] elif op == 'TOPPADDING': new.topPadding = values[0] elif op == 'BOTTOMPADDING': new.bottomPadding = values[0]
5,004
def test(): from reportlab.lib.units import inch rowheights = (24, 16, 16, 16, 16) rowheights2 = (24, 16, 16, 16, 30) colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32) data = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) data2 = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats\nLarge', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) styleSheet = getSampleStyleSheet() lst = [] lst.append(Paragraph("Tables", styleSheet['Heading1'])) lst.append(Paragraph(__doc__, styleSheet['BodyText'])) lst.append(Paragraph("The Tables (shown in different styles below) were created using the following code:", styleSheet['BodyText'])) lst.append(Preformatted(""" colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32) rowheights = (24, 16, 16, 16, 16) data = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) t = Table(data, colwidths, rowheights) """, styleSheet['Code'], dedent=4)) lst.append(Paragraph(""" You can then give the Table a TableStyle object to control its format. The first TableStyle used was created as follows: """, styleSheet['BodyText'])) lst.append(Preformatted("""
def test(): from reportlab.lib.units import inch rowheights = (24, 16, 16, 16, 16) rowheights2 = (24, 16, 16, 16, 30) colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32) data = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) data2 = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats\nLarge', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) styleSheet = getSampleStyleSheet() lst = [] lst.append(Paragraph("Tables", styleSheet['Heading1'])) lst.append(Paragraph(__doc__, styleSheet['BodyText'])) lst.append(Paragraph("The Tables (shown in different styles below) were created using the following code:", styleSheet['BodyText'])) lst.append(Preformatted(""" colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32) rowheights = (24, 16, 16, 16, 16) data = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) t = Table(data, colwidths, rowheights) """, styleSheet['Code'], dedent=4)) lst.append(Paragraph(""" You can then give the Table a TableStyle object to control its format. The first TableStyle used was created as follows: """, styleSheet['BodyText'])) lst.append(Preformatted("""
5,005
def test(): from reportlab.lib.units import inch rowheights = (24, 16, 16, 16, 16) rowheights2 = (24, 16, 16, 16, 30) colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32) data = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) data2 = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats\nLarge', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) styleSheet = getSampleStyleSheet() lst = [] lst.append(Paragraph("Tables", styleSheet['Heading1'])) lst.append(Paragraph(__doc__, styleSheet['BodyText'])) lst.append(Paragraph("The Tables (shown in different styles below) were created using the following code:", styleSheet['BodyText'])) lst.append(Preformatted(""" colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32) rowheights = (24, 16, 16, 16, 16) data = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) t = Table(data, colwidths, rowheights) """, styleSheet['Code'], dedent=4)) lst.append(Paragraph(""" You can then give the Table a TableStyle object to control its format. The first TableStyle used was created as follows: """, styleSheet['BodyText'])) lst.append(Preformatted("""
def test(): from reportlab.lib.units import inch rowheights = (24, 16, 16, 16, 16) rowheights2 = (24, 16, 16, 16, 30) colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32) data = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) data2 = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats\nLarge', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) styleSheet = getSampleStyleSheet() lst = [] lst.append(Paragraph("Tables", styleSheet['Heading1'])) lst.append(Paragraph(__doc__, styleSheet['BodyText'])) lst.append(Paragraph("The Tables (shown in different styles below) were created using the following code:", styleSheet['BodyText'])) lst.append(Preformatted(""" colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32) rowheights = (24, 16, 16, 16, 16) data = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) t = Table(data, colwidths, rowheights) """, styleSheet['Code'], dedent=4)) lst.append(Paragraph(""" You can then give the Table a TableStyle object to control its format. The first TableStyle used was created as follows: """, styleSheet['BodyText'])) lst.append(Preformatted("""
5,006
def get_version(): #determine Version if __name__=='__main__': HERE=os.path.dirname(sys.argv[0]) else: HERE=os.path.dirname(__file__) #first try source FN = pjoin(HERE,'__init__') try: for l in open(pjoin(FN+'.py'),'r').readlines(): if l.startswith('Version'): exec l return Version except: pass #don't have source, try import import imp for desc in ('.pyc', 'rb', 2), ('.pyo', 'rb', 2): try: fn = FN+desc[0] f = open(fn,desc[1]) m = imp.load_module('reportlab',f,fn,desc) return m.Version except: pass raise ValueError('Cannot determine ReportLab Version')
def get_version(): #determine Version if __name__=='__main__': HERE=os.path.dirname(sys.argv[0]) else: HERE=os.path.dirname(__file__) #first try source FN = pjoin(HERE,'__init__') try: for l in open(pjoin(FN+'.py'),'r').readlines(): if l.startswith('Version'): exec l.strip() return Version except: pass #don't have source, try import import imp for desc in ('.pyc', 'rb', 2), ('.pyo', 'rb', 2): try: fn = FN+desc[0] f = open(fn,desc[1]) m = imp.load_module('reportlab',f,fn,desc) return m.Version except: pass raise ValueError('Cannot determine ReportLab Version')
5,007
def start_stylesheet(self, args): #makes it the current style sheet. path = self._arg('stylesheet',args,'path') if path=='None': path = [] if (isinstance (path, str)): path = [path] path.append('styles') path.append(os.getcwd()) modulename = self._arg('stylesheet', args, 'module') funcname = self._arg('stylesheet', args, 'function') try: found = imp.find_module(modulename, path) (file, pathname, description) = found mod = imp.load_module(modulename, file, pathname, description) except ImportError: #last gasp mod = getModule(modulename)
def start_stylesheet(self, args): #makes it the current style sheet. path = self._arg('stylesheet',args,'path') if path=='None': path = [] if type(path) not in SeqTypes: path = [path] path.append('styles') path.append(os.getcwd()) modulename = self._arg('stylesheet', args, 'module') funcname = self._arg('stylesheet', args, 'function') try: found = imp.find_module(modulename, path) (file, pathname, description) = found mod = imp.load_module(modulename, file, pathname, description) except ImportError: #last gasp mod = getModule(modulename)
5,008
def wrap(self, availWidth, availHeight): """This will be called by the enclosing frame before objects are asked their size, drawn or whatever. It returns the size actually used.""" return (self.width, self.height)
def wrap(self, availWidth, availHeight): """This will be called by the enclosing frame before objects are asked their size, drawn or whatever. It returns the size actually used.""" return (self.width, self.height)
5,009
def _setOpt(name, value, conv=None): '''set a module level value from environ/default''' from os import environ ename = 'RL_'+name if environ.has_key(ename): value = environ[ename] if conv: value = conv(value) globals()[name] = value
def _setOpt(name, value, conv=None): '''set a module level value from environ/default''' from os import environ ename = 'RL_'+name if environ.has_key(ename): value = environ[ename] if conv: value = conv(value) globals()[name] = value
5,010
def _setOpt(name, value, conv=None): '''set a module level value from environ/default''' from os import environ ename = 'RL_'+name if environ.has_key(ename): value = environ[ename] if conv: value = conv(value) globals()[name] = value
def _setOpt(name, value, conv=None): '''set a module level value from environ/default''' from os import environ ename = 'RL_'+name if environ.has_key(ename): value = environ[ename] if conv: value = conv(value) globals()[name] = value
5,011
def _addCommand(self,cmd): if cmd[0] in ('BACKGROUND','ROWBACKGROUNDS','COLBACKGROUNDS'): self._bkgrndcmds.append(cmd) elif cmd[0] == 'SPAN': self._spanCmds.append(cmd) elif _isLineCommand(cmd): # we expect op, start, stop, weight, colour, cap, dashes, join cmd = tuple(cmd) if len(cmd)<5: raise ValueError('bad line command '+str(cmd))
def _addCommand(self,cmd): if cmd[0] in ('BACKGROUND','ROWBACKGROUNDS','COLBACKGROUNDS'): self._bkgrndcmds.append(cmd) elif cmd[0] == 'SPAN': self._spanCmds.append(cmd) elif _isLineCommand(cmd): # we expect op, start, stop, weight, colour, cap, dashes, join cmd = tuple(cmd) if len(cmd)<5: raise ValueError('bad line command '+str(cmd))
5,012
def _addCommand(self,cmd): if cmd[0] in ('BACKGROUND','ROWBACKGROUNDS','COLBACKGROUNDS'): self._bkgrndcmds.append(cmd) elif cmd[0] == 'SPAN': self._spanCmds.append(cmd) elif _isLineCommand(cmd): # we expect op, start, stop, weight, colour, cap, dashes, join cmd = tuple(cmd) if len(cmd)<5: raise ValueError('bad line command '+str(cmd))
def _addCommand(self,cmd): if cmd[0] in ('BACKGROUND','ROWBACKGROUNDS','COLBACKGROUNDS'): self._bkgrndcmds.append(cmd) elif cmd[0] == 'SPAN': self._spanCmds.append(cmd) elif _isLineCommand(cmd): # we expect op, start, stop, weight, colour, cap, dashes, join cmd = tuple(cmd) if len(cmd)<5: raise ValueError('bad line command '+str(cmd))
5,013
def _addCommand(self,cmd): if cmd[0] in ('BACKGROUND','ROWBACKGROUNDS','COLBACKGROUNDS'): self._bkgrndcmds.append(cmd) elif cmd[0] == 'SPAN': self._spanCmds.append(cmd) elif _isLineCommand(cmd): # we expect op, start, stop, weight, colour, cap, dashes, join cmd = tuple(cmd) if len(cmd)<5: raise ValueError('bad line command '+str(cmd))
def _addCommand(self,cmd): if cmd[0] in ('BACKGROUND','ROWBACKGROUNDS','COLBACKGROUNDS'): self._bkgrndcmds.append(cmd) elif cmd[0] == 'SPAN': self._spanCmds.append(cmd) elif _isLineCommand(cmd): # we expect op, start, stop, weight, colour, cap, dashes, join cmd = tuple(cmd) if len(cmd)<5: raise ValueError('bad line command '+str(cmd))
5,014
def _addCommand(self,cmd): if cmd[0] in ('BACKGROUND','ROWBACKGROUNDS','COLBACKGROUNDS'): self._bkgrndcmds.append(cmd) elif cmd[0] == 'SPAN': self._spanCmds.append(cmd) elif _isLineCommand(cmd): # we expect op, start, stop, weight, colour, cap, dashes, join cmd = tuple(cmd) if len(cmd)<5: raise ValueError('bad line command '+str(cmd))
def _addCommand(self,cmd): if cmd[0] in ('BACKGROUND','ROWBACKGROUNDS','COLBACKGROUNDS'): self._bkgrndcmds.append(cmd) elif cmd[0] == 'SPAN': self._spanCmds.append(cmd) elif _isLineCommand(cmd): # we expect op, start, stop, weight, colour, cap, dashes, join cmd = tuple(cmd) if len(cmd)<5: raise ValueError('bad line command '+str(cmd))
5,015
def _addCommand(self,cmd): if cmd[0] in ('BACKGROUND','ROWBACKGROUNDS','COLBACKGROUNDS'): self._bkgrndcmds.append(cmd) elif cmd[0] == 'SPAN': self._spanCmds.append(cmd) elif _isLineCommand(cmd): # we expect op, start, stop, weight, colour, cap, dashes, join cmd = tuple(cmd) if len(cmd)<5: raise ValueError('bad line command '+str(cmd))
def _addCommand(self,cmd): if cmd[0] in ('BACKGROUND','ROWBACKGROUNDS','COLBACKGROUNDS'): self._bkgrndcmds.append(cmd) elif cmd[0] == 'SPAN': self._spanCmds.append(cmd) elif _isLineCommand(cmd): # we expect op, start, stop, weight, colour, cap, dashes, join cmd = tuple(cmd) if len(cmd)<5: raise ValueError('bad line command '+str(cmd))
5,016
def drawit(F,w=400,h=200,fontSize=12,slack=2,gap=5): D = Drawing(w,h) th = 2*gap + fontSize*1.2 gh = gap + .2*fontSize y = h maxx = 0 for fontName in F: y -= th text = fontName+": I should be totally horizontal and enclosed in a box" textWidth = stringWidth(text, fontName, fontSize) maxx = max(maxx,textWidth+20) D.add( Group(Rect(8, y-gh, textWidth + 4, th, strokeColor=colors.red, strokeWidth=.5, fillColor=colors.lightgrey), String(10, y, text, fontName=fontName, fontSize = fontSize))) y -= 5 return maxx, h-y+gap, D
def drawit(F,w=400,h=200,fontSize=12,slack=2,gap=5): D = Drawing(w,h) th = 2*gap + fontSize*1.2 gh = gap + .2*fontSize y = h maxx = 0 for fontName in F: y -= th text = fontName+": I should be totally horizontal and enclosed in a box" textWidth = stringWidth(text, fontName, fontSize) maxx = max(maxx,textWidth+20) D.add( Group(Rect(8, y-gh, textWidth + 4, th, strokeColor=colors.red, strokeWidth=.5, fillColor=colors.lightgrey), String(10, y, text, fontName=fontName, fontSize = fontSize))) y -= 5 return maxx, h-y+gap, D
5,017
def cvs_checkout(d): os.chdir(d) recursive_rmdir(cvsdir) cvs = find_exe('cvs') if cvs is None: print "Can't find cvs anywhere on the path" os.exit(1) if release: print release os.environ['CVSROOT']=':ext:%s@cvs1:/cvsroot/reportlab' % USER #do_exec(cvs+(' rtag %s' % release), 'the tag phase') do_exec(cvs+(' co -r %s reportlab'%release), 'the download phase') else: os.environ['CVSROOT']=':pserver:%s@cvs1:/cvsroot/reportlab' % USER do_exec(cvs+' co reportlab', 'the download phase')
defdo_exec(cvs+(' rtag %s' % release), 'the tag phase') cvs_checkout(d):do_exec(cvs+(' rtag %s' % release), 'the tag phase') os.chdir(d)do_exec(cvs+(' rtag %s' % release), 'the tag phase') recursive_rmdir(cvsdir)do_exec(cvs+(' rtag %s' % release), 'the tag phase') do_exec(cvs+(' rtag %s' % release), 'the tag phase') cvsdo_exec(cvs+(' rtag %s' % release), 'the tag phase') =do_exec(cvs+(' rtag %s' % release), 'the tag phase') find_exe('cvs')do_exec(cvs+(' rtag %s' % release), 'the tag phase') ifdo_exec(cvs+(' rtag %s' % release), 'the tag phase') cvsdo_exec(cvs+(' rtag %s' % release), 'the tag phase') isdo_exec(cvs+(' rtag %s' % release), 'the tag phase') None:do_exec(cvs+(' rtag %s' % release), 'the tag phase') printdo_exec(cvs+(' rtag %s' % release), 'the tag phase') "Can'tdo_exec(cvs+(' rtag %s' % release), 'the tag phase') finddo_exec(cvs+(' rtag %s' % release), 'the tag phase') cvsdo_exec(cvs+(' rtag %s' % release), 'the tag phase') anywheredo_exec(cvs+(' rtag %s' % release), 'the tag phase') ondo_exec(cvs+(' rtag %s' % release), 'the tag phase') thedo_exec(cvs+(' rtag %s' % release), 'the tag phase') path"do_exec(cvs+(' rtag %s' % release), 'the tag phase') os.exit(1)do_exec(cvs+(' rtag %s' % release), 'the tag phase') do_exec(cvs+(' rtag %s' % release), 'the tag phase') ifdo_exec(cvs+(' rtag %s' % release), 'the tag phase') release:do_exec(cvs+(' rtag %s' % release), 'the tag phase') printdo_exec(cvs+(' rtag %s' % release), 'the tag phase') releasedo_exec(cvs+(' rtag %s' % release), 'the tag phase') os.environ['CVSROOT']=':ext:%s@cvs1:/cvsroot/reportlab'do_exec(cvs+(' rtag %s' % release), 'the tag phase') %do_exec(cvs+(' rtag %s' % release), 'the tag phase') USERdo_exec(cvs+(' rtag %s' % release), 'the tag phase') #do_exec(cvs+('do_exec(cvs+(' rtag %s' % release), 'the tag phase') rtagdo_exec(cvs+(' rtag %s' % release), 'the tag phase') %s'do_exec(cvs+(' rtag %s' % release), 'the tag phase') %do_exec(cvs+(' rtag %s' % release), 'the tag phase') release),do_exec(cvs+(' rtag %s' % release), 'the tag phase') 'thedo_exec(cvs+(' rtag %s' % release), 'the tag phase') tagdo_exec(cvs+(' rtag %s' % release), 'the tag phase') phase')do_exec(cvs+(' rtag %s' % release), 'the tag phase') do_exec(cvs+('do_exec(cvs+(' rtag %s' % release), 'the tag phase') codo_exec(cvs+(' rtag %s' % release), 'the tag phase') -rdo_exec(cvs+(' rtag %s' % release), 'the tag phase') %sdo_exec(cvs+(' rtag %s' % release), 'the tag phase') reportlab'%release),do_exec(cvs+(' rtag %s' % release), 'the tag phase') 'thedo_exec(cvs+(' rtag %s' % release), 'the tag phase') downloaddo_exec(cvs+(' rtag %s' % release), 'the tag phase') phase')do_exec(cvs+(' rtag %s' % release), 'the tag phase') else:do_exec(cvs+(' rtag %s' % release), 'the tag phase') os.environ['CVSROOT']=':pserver:%s@cvs1:/cvsroot/reportlab'do_exec(cvs+(' rtag %s' % release), 'the tag phase') %do_exec(cvs+(' rtag %s' % release), 'the tag phase') USERdo_exec(cvs+(' rtag %s' % release), 'the tag phase') do_exec(cvs+'do_exec(cvs+(' rtag %s' % release), 'the tag phase') codo_exec(cvs+(' rtag %s' % release), 'the tag phase') reportlab',do_exec(cvs+(' rtag %s' % release), 'the tag phase') 'thedo_exec(cvs+(' rtag %s' % release), 'the tag phase') downloaddo_exec(cvs+(' rtag %s' % release), 'the tag phase') phase')do_exec(cvs+(' rtag %s' % release), 'the tag phase')
5,018
def setTextOrigin(self, x, y): if self._canvas.bottomup: self._code.append('1 0 0 1 %s Tm' % fp_str(x, y)) #bottom up else: self._code.append('1 0 0 -1 %s Tm' % fp_str(x, y)) #top down self._x = x self._y = y self._x0 = x #the margin
def setTextOrigin(self, x, y): if self._canvas.bottomup: self._code.append('1 0 0 1 %s Tm' % fp_str(x, y)) #bottom up else: self._code.append('1 0 0 -1 %s Tm' % fp_str(x, y)) #top down self._x0 = self._x = x self._y0 = self._y = y #the margin
5,019
def setTextTransform(self, a, b, c, d, e, f): "Like setTextOrigin, but does rotation, scaling etc." if not self._canvas.bottomup: c = -c #reverse bottom row of the 2D Transform d = -d self._code.append('%s Tm' % fp_str(a, b, c, d, e, f)) #we only measure coords relative to present text matrix self._x = e self._y = f
def setTextTransform(self, a, b, c, d, e, f): "Like setTextOrigin, but does rotation, scaling etc." if not self._canvas.bottomup: c = -c #reverse bottom row of the 2D Transform d = -d self._code.append('%s Tm' % fp_str(a, b, c, d, e, f)) #we only measure coords relative to present text matrix self._x = e self._y = f
5,020
def moveCursor(self, dx, dy): """Moves to a point dx, dy away from the start of the current line - NOT from the current point! So if you call it in mid-sentence, watch out.""" if self._code and self._code[-1][-3:]==' Td': L = string.split(self._code[-1]) if len(L)==3: del self._code[-1] else: self._code[-1] = string.join(L[:-4]) dx = dx + float(L[-3]) dy = dy - float(L[-2]) self._code.append('%s Td' % fp_str(dx, -dy))
def moveCursor(self, dx, dy): """Starts a new line at an offset dx,dy from the start of the current line. This does not move the cursor relative to the current position, and it changes the current offset of every future line drawn (i.e. if you next do a textLine() call, it will move the cursor to a position one line lower than the position specificied in this call. """ if self._code and self._code[-1][-3:]==' Td': L = string.split(self._code[-1]) if len(L)==3: del self._code[-1] else: self._code[-1] = string.join(L[:-4]) dx = dx + float(L[-3]) dy = dy - float(L[-2]) self._code.append('%s Td' % fp_str(dx, -dy))
5,021
def moveCursor(self, dx, dy): """Moves to a point dx, dy away from the start of the current line - NOT from the current point! So if you call it in mid-sentence, watch out.""" if self._code and self._code[-1][-3:]==' Td': L = string.split(self._code[-1]) if len(L)==3: del self._code[-1] else: self._code[-1] = string.join(L[:-4]) dx = dx + float(L[-3]) dy = dy - float(L[-2]) self._code.append('%s Td' % fp_str(dx, -dy))
def moveCursor(self, dx, dy): """Moves to a point dx, dy away from the start of the current line - NOT from the current point! So if you call it in mid-sentence, watch out.""" if self._code and self._code[-1][-3:]==' Td': L = string.split(self._code[-1]) if len(L)==3: del self._code[-1] else: self._code[-1] = string.join(L[:-4]) lastDx = float(L[-3]) lastDy = float(L[-2]) dx += lastDx dy -= lastDy self._x0 -= lastDx self._y0 -= lastDy self._code.append('%s Td' % fp_str(dx, -dy))
5,022
def setXPos(self, dx): """Moves to a point dx away from the start of the current line - NOT from the current point! So if you call it in mid-sentence, watch out.""" self.moveCursor(dx,0)
def setXPos(self, dx): """Starts a new line dx away from the start of the current line - NOT from the current point! So if you call it in mid-sentence, watch out.""" self.moveCursor(dx,0)
5,023
def textLines(self, stuff, trim=1): """prints multi-line or newlined strings, moving down. One comon use is to quote a multi-line block in your Python code; since this may be indented, by default it trims whitespace off each line and from the beginning; set trim=0 to preserve whitespace.""" if type(stuff) == StringType: lines = string.split(string.strip(stuff), '\n') if trim==1: lines = map(string.strip,lines) elif type(stuff) == ListType: lines = stuff elif type(stuff) == TupleType: lines = stuff else: assert 1==0, "argument to textlines must be string,, list or tuple"
def textLines(self, stuff, trim=1): """prints multi-line or newlined strings, moving down. One comon use is to quote a multi-line block in your Python code; since this may be indented, by default it trims whitespace off each line and from the beginning; set trim=0 to preserve whitespace.""" if type(stuff) == StringType: lines = string.split(string.strip(stuff), '\n') if trim==1: lines = map(string.strip,lines) elif type(stuff) == ListType: lines = stuff elif type(stuff) == TupleType: lines = stuff else: assert 1==0, "argument to textlines must be string,, list or tuple"
5,024
def findT1File(fontName,ext='.pfb'): from reportlab.rl_config import T1SearchPath assert T1SearchPath!=[], "No Type-1 font search path" if sys.platform in ('linux2',) and ext='.pfb': ext = '' n = _findFNR(fontName)+ext for d in T1SearchPath: f = os.path.join(d,n) if os.path.isfile(f): return f return None
def findT1File(fontName,ext='.pfb'): from reportlab.rl_config import T1SearchPath assert T1SearchPath!=[], "No Type-1 font search path" if sys.platform in ('linux2',) and ext=='.pfb': ext = '' n = _findFNR(fontName)+ext for d in T1SearchPath: f = os.path.join(d,n) if os.path.isfile(f): return f return None
5,025
def __init__(self): self.strokeWidth = 0 self.fillColor = None self.strokeColor = STATE_DEFAULTS["strokeColor"] self.strokeDashArray = STATE_DEFAULTS["strokeDashArray"] self.popout = 0 self.fontName = STATE_DEFAULTS["fontName"] self.fontSize = STATE_DEFAULTS["fontSize"] self.fontColor = STATE_DEFAULTS["fillColor"] self.labelRadius = 1.2
def __init__(self): self.strokeWidth = 0 self.fillColor = None self.strokeColor = STATE_DEFAULTS["strokeColor"] self.strokeDashArray = STATE_DEFAULTS["strokeDashArray"] self.popout = 0 self.fontName = STATE_DEFAULTS["fontName"] self.fontSize = STATE_DEFAULTS["fontSize"] self.fontColor = STATE_DEFAULTS["fillColor"] self.labelRadius = 1.2
5,026
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] for l in self.data: t = self.normalizeData(l) normData.append(t) else: normData = self.normalizeData(self.data) n = len(normData)
def makeSectors(self): # normalize slice data if type(self.data) in (ListType, TupleType) and type(self.data[0]) in (ListType, TupleType): #it's a nested list, more than one sequence normData = [] for l in self.data: t = self.normalizeData(l) normData.append(t) else: normData = self.normalizeData(self.data) n = len(normData)
5,027
def buildup_test(cls=test_pyRXPU,I=[]): ''' Add test methods to the TestCase ''' cls.valid = [] cls.invalid = [] cls.notwf = [] testdir = os.path.dirname(__file__) try: zipf = zipfile.ZipFile(os.path.join(testdir,'xmltest.zip')) except: print >> sys.stderr, "Can't locate file xmltest.zip\nPerhaps it should be downloaded from\nhttp://www.reportlab.com/ftp/xmltest.zip\nor\nftp://ftp.jclark.com/pub/xml/xmltest.zip\n" raise for zipname in zipf.namelist(): # Extract the files if they don't alrady exist osname = os.path.join(*zipname.split('/')) # For non-unixes osname = os.path.join(testdir,osname) dir = os.path.dirname(osname) if not os.path.isdir(dir): os.makedirs(dir) if not os.path.isfile(osname): f = open(osname,'wb') f.write(zipf.read(zipname)) f.close() if I and inname not in I: continue # Add input files to our lists if os.path.splitext(osname)[1] == '.xml' and zipname.find('out') == -1: if zipname.find('invalid') != -1: cls.invalid.append(osname) elif zipname.find('not-wf') != -1: cls.notwf.append(osname) elif zipname.find('valid') != -1: outname = os.path.join(dir,'out',os.path.basename(osname)) cls.valid.append( (osname,outname) ) # Add 'valid' tests for inname,outname in cls.valid: num = int(os.path.splitext(os.path.basename(inname))[0]) dir = os.path.split(os.path.split(inname)[0])[1] mname = 'test_Valid_%s_%03d' % (dir,num) def doTest(self,inname=inname,outname=outname): self._test_valid(inname,outname) setattr(cls,mname,doTest) # Add 'invalid' tests for inname in cls.invalid: num = int(os.path.splitext(os.path.basename(inname))[0]) mname = 'test_InvalidParse_%03d' % (num) def doTest(self,inname=inname): self._test_invalid_parse(inname) setattr(cls,mname,doTest) mname = 'test_InvalidValidate_%03d' % (num) def doTest(self,inname=inname): self._test_invalid_validate(inname) setattr(cls,mname,doTest) # Add 'not wellformed' tests for inname in cls.notwf: num = int(os.path.splitext(os.path.basename(inname))[0]) dir = os.path.split(os.path.split(inname)[0])[1] mname = 'test_NotWellFormed_%s_%03d' % (dir,num) def doTest(self,inname=inname): self._test_notwf(inname) setattr(cls,mname,doTest)
def buildup_test(cls=test_pyRXPU,I=[]): ''' Add test methods to the TestCase ''' cls.valid = [] cls.invalid = [] cls.notwf = [] testdir = os.path.dirname(__file__) try: zipf = zipfile.ZipFile(os.path.join(testdir,'xmltest.zip')) except: print >> sys.stderr, "Can't locate file xmltest.zip\nPerhaps it should be downloaded from\nhttp://www.reportlab.com/ftp/xmltest.zip\nor\nftp://ftp.jclark.com/pub/xml/xmltest.zip\n" raise for zipname in zipf.namelist(): # Extract the files if they don't alrady exist osname = os.path.join(*zipname.split('/')) # For non-unixes osname = os.path.join(testdir,osname) dir = os.path.dirname(osname) if not os.path.isdir(dir): os.makedirs(dir) if not os.path.isfile(osname): f = open(osname,'wb') f.write(zipf.read(zipname)) f.close() if I and zipname not in I: continue # Add input files to our lists if os.path.splitext(osname)[1] == '.xml' and zipname.find('out') == -1: if zipname.find('invalid') != -1: cls.invalid.append(osname) elif zipname.find('not-wf') != -1: cls.notwf.append(osname) elif zipname.find('valid') != -1: outname = os.path.join(dir,'out',os.path.basename(osname)) cls.valid.append( (osname,outname) ) # Add 'valid' tests for inname,outname in cls.valid: num = int(os.path.splitext(os.path.basename(inname))[0]) dir = os.path.split(os.path.split(inname)[0])[1] mname = 'test_Valid_%s_%03d' % (dir,num) def doTest(self,inname=inname,outname=outname): self._test_valid(inname,outname) setattr(cls,mname,doTest) # Add 'invalid' tests for inname in cls.invalid: num = int(os.path.splitext(os.path.basename(inname))[0]) mname = 'test_InvalidParse_%03d' % (num) def doTest(self,inname=inname): self._test_invalid_parse(inname) setattr(cls,mname,doTest) mname = 'test_InvalidValidate_%03d' % (num) def doTest(self,inname=inname): self._test_invalid_validate(inname) setattr(cls,mname,doTest) # Add 'not wellformed' tests for inname in cls.notwf: num = int(os.path.splitext(os.path.basename(inname))[0]) dir = os.path.split(os.path.split(inname)[0])[1] mname = 'test_NotWellFormed_%s_%03d' % (dir,num) def doTest(self,inname=inname): self._test_notwf(inname) setattr(cls,mname,doTest)
5,028
def SaveToFile(self, filename,canvas): """Open a file, and ask each object in turn to write itself to the file. Keep track of the file position at each point for use in the index at the end"""
def SaveToFile(self, filename,canvas): """Open a file, and ask each object in turn to write itself to the file. Keep track of the file position at each point for use in the index at the end"""
5,029
def SaveToFile(self, filename,canvas): """Open a file, and ask each object in turn to write itself to the file. Keep track of the file position at each point for use in the index at the end"""
def SaveToFile(self, filename,canvas): """Open a file, and ask each object in turn to write itself to the file. Keep track of the file position at each point for use in the index at the end"""
5,030
def Reference(self, object, name=None): ### note references may "grow" during the final formatting pass: don't use d.keys()! # don't make references to other references, or non instances from types import InstanceType #print"object type is ", type(object) tob = type(object) if (tob is not InstanceType) or (tob is InstanceType and object.__class__ is PDFObjectReference): return object idToObject = self.idToObject if hasattr(object, __InternalName__): # already registered intname = object.__InternalName__ if name is not None and name!=intname: raise ValueError, "attempt to reregister object %s with new name %s" % ( repr(intname), repr(name)) if not idToObject.has_key(intname): raise ValueError, "object named but not registered" return PDFObjectReference(intname) # otherwise register the new object objectcounter = self.objectcounter = self.objectcounter+1 if name is None: name = "R"+repr(objectcounter) if idToObject.has_key(name): raise ValueError, "redefining named object: "+repr(name) object.__InternalName__ = name #print "name", name, "counter", objectcounter self.idToObjectNumberAndVersion[name] = (objectcounter, 0) self.numberToId[objectcounter] = name idToObject[name] = object return PDFObjectReference(name)
def Reference(self, object, name=None): ### note references may "grow" during the final formatting pass: don't use d.keys()! # don't make references to other references, or non instances from types import InstanceType #print"object type is ", type(object) tob = type(object) if (tob is not InstanceType) or (tob is InstanceType and object.__class__ is PDFObjectReference): return object idToObject = self.idToObject if hasattr(object, __InternalName__): # already registered intname = object.__InternalName__ if name is not None and name!=intname: raise ValueError, "attempt to reregister object %s with new name %s" % ( repr(intname), repr(name)) if not idToObject.has_key(intname): raise ValueError, "object named but not registered" return PDFObjectReference(intname) # otherwise register the new object objectcounter = self.objectcounter = self.objectcounter+1 if name is None: name = "R"+repr(objectcounter) if idToObject.has_key(name): raise ValueError, "redefining named object: "+repr(name) object.__InternalName__ = name #print "name", name, "counter", objectcounter self.idToObjectNumberAndVersion[name] = (objectcounter, 0) self.numberToId[objectcounter] = name idToObject[name] = object return PDFObjectReference(name)
5,031
def Reference(self, object, name=None): ### note references may "grow" during the final formatting pass: don't use d.keys()! # don't make references to other references, or non instances from types import InstanceType #print"object type is ", type(object) tob = type(object) if (tob is not InstanceType) or (tob is InstanceType and object.__class__ is PDFObjectReference): return object idToObject = self.idToObject if hasattr(object, __InternalName__): # already registered intname = object.__InternalName__ if name is not None and name!=intname: raise ValueError, "attempt to reregister object %s with new name %s" % ( repr(intname), repr(name)) if not idToObject.has_key(intname): raise ValueError, "object named but not registered" return PDFObjectReference(intname) # otherwise register the new object objectcounter = self.objectcounter = self.objectcounter+1 if name is None: name = "R"+repr(objectcounter) if idToObject.has_key(name): raise ValueError, "redefining named object: "+repr(name) object.__InternalName__ = name #print "name", name, "counter", objectcounter self.idToObjectNumberAndVersion[name] = (objectcounter, 0) self.numberToId[objectcounter] = name idToObject[name] = object return PDFObjectReference(name)
def Reference(self, object, name=None): ### note references may "grow" during the final formatting pass: don't use d.keys()! # don't make references to other references, or non instances from types import InstanceType #print"object type is ", type(object) tob = type(object) idToObject = self.idToObject if name is None and ( (tob is not InstanceType) or (tob is InstanceType and object.__class__ is PDFObjectReference)): return object idToObject = self.idToObject if hasattr(object, __InternalName__): # already registered intname = object.__InternalName__ if name is not None and name!=intname: raise ValueError, "attempt to reregister object %s with new name %s" % ( repr(intname), repr(name)) if not idToObject.has_key(intname): raise ValueError, "object named but not registered" return PDFObjectReference(intname) # otherwise register the new object objectcounter = self.objectcounter = self.objectcounter+1 if name is None: name = "R"+repr(objectcounter) if idToObject.has_key(name): raise ValueError, "redefining named object: "+repr(name) object.__InternalName__ = name #print "name", name, "counter", objectcounter self.idToObjectNumberAndVersion[name] = (objectcounter, 0) self.numberToId[objectcounter] = name idToObject[name] = object return PDFObjectReference(name)
5,032
def Reference(self, object, name=None): ### note references may "grow" during the final formatting pass: don't use d.keys()! # don't make references to other references, or non instances from types import InstanceType #print"object type is ", type(object) tob = type(object) if (tob is not InstanceType) or (tob is InstanceType and object.__class__ is PDFObjectReference): return object idToObject = self.idToObject if hasattr(object, __InternalName__): # already registered intname = object.__InternalName__ if name is not None and name!=intname: raise ValueError, "attempt to reregister object %s with new name %s" % ( repr(intname), repr(name)) if not idToObject.has_key(intname): raise ValueError, "object named but not registered" return PDFObjectReference(intname) # otherwise register the new object objectcounter = self.objectcounter = self.objectcounter+1 if name is None: name = "R"+repr(objectcounter) if idToObject.has_key(name): raise ValueError, "redefining named object: "+repr(name) object.__InternalName__ = name #print "name", name, "counter", objectcounter self.idToObjectNumberAndVersion[name] = (objectcounter, 0) self.numberToId[objectcounter] = name idToObject[name] = object return PDFObjectReference(name)
def Reference(self, object, name=None): ### note references may "grow" during the final formatting pass: don't use d.keys()! # don't make references to other references, or non instances from types import InstanceType #print"object type is ", type(object) tob = type(object) if (tob is not InstanceType) or (tob is InstanceType and object.__class__ is PDFObjectReference): return object if hasattr(object, __InternalName__): # already registered intname = object.__InternalName__ if name is not None and name!=intname: raise ValueError, "attempt to reregister object %s with new name %s" % ( repr(intname), repr(name)) if not idToObject.has_key(intname): raise ValueError, "object named but not registered" return PDFObjectReference(intname) # otherwise register the new object objectcounter = self.objectcounter = self.objectcounter+1 if name is None: name = "R"+repr(objectcounter) if idToObject.has_key(name): raise ValueError, "redefining named object: "+repr(name) object.__InternalName__ = name #print "name", name, "counter", objectcounter self.idToObjectNumberAndVersion[name] = (objectcounter, 0) self.numberToId[objectcounter] = name idToObject[name] = object return PDFObjectReference(name)
5,033
def Reference(self, object, name=None): ### note references may "grow" during the final formatting pass: don't use d.keys()! # don't make references to other references, or non instances from types import InstanceType #print"object type is ", type(object) tob = type(object) if (tob is not InstanceType) or (tob is InstanceType and object.__class__ is PDFObjectReference): return object idToObject = self.idToObject if hasattr(object, __InternalName__): # already registered intname = object.__InternalName__ if name is not None and name!=intname: raise ValueError, "attempt to reregister object %s with new name %s" % ( repr(intname), repr(name)) if not idToObject.has_key(intname): raise ValueError, "object named but not registered" return PDFObjectReference(intname) # otherwise register the new object objectcounter = self.objectcounter = self.objectcounter+1 if name is None: name = "R"+repr(objectcounter) if idToObject.has_key(name): raise ValueError, "redefining named object: "+repr(name) object.__InternalName__ = name #print "name", name, "counter", objectcounter self.idToObjectNumberAndVersion[name] = (objectcounter, 0) self.numberToId[objectcounter] = name idToObject[name] = object return PDFObjectReference(name)
def Reference(self, object, name=None): ### note references may "grow" during the final formatting pass: don't use d.keys()! # don't make references to other references, or non instances from types import InstanceType #print"object type is ", type(object) tob = type(object) if (tob is not InstanceType) or (tob is InstanceType and object.__class__ is PDFObjectReference): return object idToObject = self.idToObject if hasattr(object, __InternalName__): # already registered intname = object.__InternalName__ if name is not None and name!=intname: raise ValueError, "attempt to reregister object %s with new name %s" % ( repr(intname), repr(name)) if not idToObject.has_key(intname): raise ValueError, "object named but not registered" return PDFObjectReference(intname) # otherwise register the new object objectcounter = self.objectcounter = self.objectcounter+1 if name is None: name = "R"+repr(objectcounter) if idToObject.has_key(name): other = idToObject[name] if other!=object: raise ValueError, "redefining named object: "+repr(name) return PDFObjectReference(name) if tob is InstanceType: object.__InternalName__ = name #print "name", name, "counter", objectcounter self.idToObjectNumberAndVersion[name] = (objectcounter, 0) self.numberToId[objectcounter] = name idToObject[name] = object return PDFObjectReference(name)
5,034
def __init__(self, data, colWidths=None, rowHeights=None, style=None, repeatRows=0, repeatCols=0, splitByRow=1, emptyTableAction=None): #print "colWidths", colWidths self.hAlign = 'CENTER' self.vAlign = 'MIDDLE' if type(data) not in _SeqTypes: raise ValueError, "%s invalid data type" % self.identity() self._nrows = nrows = len(data) if nrows: self._ncols = ncols = max(map(_rowLen,data)) elif colWidths: ncols = len(colWidths) else: ncols = 0 if not emptyTableAction: emptyTableAction = rl_config.emptyTableAction if not (nrows and ncols): if emptyTableAction=='error': raise ValueError, "%s must have at least a row and column" % self.identity() elif emptyTableAction=='indicate': self.__class__ = Preformatted global _emptyTableStyle if '_emptyTableStyle' not in globals().keys(): _emptyTableStyle = ParagraphStyle('_emptyTableStyle') _emptyTableStyle.textColor = colors.red _emptyTableStyle.backColor = colors.yellow Preformatted.__init__(self,'Table(%d,%d)' % (nrows,ncols), _emptyTableStyle) elif emptyTableAction=='ignore': self.__class__ = Spacer Spacer.__init__(self,0,0) else: raise ValueError, '%s bad emptyTableAction: "%s"' % (self.identity(),emptyTableAction) return
def __init__(self, data, colWidths=None, rowHeights=None, style=None, repeatRows=0, repeatCols=0, splitByRow=1, emptyTableAction=None): #print "colWidths", colWidths self.hAlign = 'CENTER' self.vAlign = 'MIDDLE' if type(data) not in _SeqTypes: raise ValueError, "%s invalid data type" % self.identity() self._nrows = nrows = len(data) if nrows: self._ncols = ncols = max(map(_rowLen,data)) elif colWidths: ncols = len(colWidths) else: ncols = 0 if not emptyTableAction: emptyTableAction = rl_config.emptyTableAction if not (nrows and ncols): if emptyTableAction=='error': raise ValueError, "%s must have at least a row and column" % self.identity() elif emptyTableAction=='indicate': self.__class__ = Preformatted global _emptyTableStyle if '_emptyTableStyle' not in globals().keys(): _emptyTableStyle = ParagraphStyle('_emptyTableStyle') _emptyTableStyle.textColor = colors.red _emptyTableStyle.backColor = colors.yellow Preformatted.__init__(self,'Table(%d,%d)' % (nrows,ncols), _emptyTableStyle) elif emptyTableAction=='ignore': self.__class__ = Spacer Spacer.__init__(self,0,0) else: raise ValueError, '%s bad emptyTableAction: "%s"' % (self.identity(),emptyTableAction) return
5,035
def identity(self, maxLen=30): '''Identify our selves as well as possible''' vx = None nr = self._nrows if not hasattr(self,'_ncols'): nc = 'unknown' else: nc = self._ncols cv = self._cellvalues b = 0 for i in xrange(nr): for j in xrange(nc): v = cv[i][j] t = type(v) if t in _SeqTypes or isinstance(v,Flowable): if not t in _SeqTypes: v = (v,) r = '' for vij in v: r = vij.identity(maxLen) if r and r[-4:]!='>...': break if r and r[-4:]!='>...': ix, jx, vx, b = i, j, r, 1 else: v = v is None and '' or str(v) ix, jx, vx = i, j, v b = (vx and t is StringType) and 1 or 0 if maxLen: vx = vx[:maxLen] if b: break if b: break if vx: vx = ' with cell(%d,%d) containing\n%s' % (ix,jx,repr(vx)) else: vx = '...'
def identity(self, maxLen=30): '''Identify our selves as well as possible''' vx = None nr = getattr(self,'_nrows','unknown') nc = getattr(self,'_ncols','unknown') cv = self._cellvalues if cv and 'unknown' not in (nr,nc): b = 0 for i in xrange(nr): for j in xrange(nc): v = cv[i][j] t = type(v) if t in _SeqTypes or isinstance(v,Flowable): if not t in _SeqTypes: v = (v,) r = '' for vij in v: r = vij.identity(maxLen) if r and r[-4:]!='>...': break if r and r[-4:]!='>...': ix, jx, vx, b = i, j, r, 1 else: v = v is None and '' or str(v) ix, jx, vx = i, j, v b = (vx and t is StringType) and 1 or 0 if maxLen: vx = vx[:maxLen] if b: break if b: break if vx: vx = ' with cell(%d,%d) containing\n%s' % (ix,jx,repr(vx)) else: vx = '...'
5,036
def checkMood(moodName): return (moodName in ('happy','sad','ok'))
def checkMood(moodName): return (moodName in ('happy','sad','ok'))
5,037
def checkMood(moodName): return (moodName in ('happy','sad','ok'))
def checkMood(moodName): return (moodName in ('happy','sad','ok'))
5,038
def checkMood(moodName): return (moodName in ('happy','sad','ok'))
def checkMood(moodName): return (moodName in ('happy','sad','ok'))
5,039
def checkMood(moodName): return (moodName in ('happy','sad','ok'))
def checkMood(moodName): return (moodName in ('happy','sad','ok'))
5,040
def checkMood(moodName): return (moodName in ('happy','sad','ok'))
def checkMood(moodName): return (moodName in ('happy','sad','ok'))
5,041
def checkMood(moodName): return (moodName in ('happy','sad','ok'))
def checkMood(moodName): return (moodName in ('happy','sad','ok'))
5,042
def checkMood(moodName): return (moodName in ('happy','sad','ok'))
def checkMood(moodName): return (moodName in ('happy','sad','ok'))
5,043
def checkMood(moodName): return (moodName in ('happy','sad','ok'))
def checkMood(moodName): return (moodName in ('happy','sad','ok'))
5,044
def checkMood(moodName): return (moodName in ('happy','sad','ok'))
def checkMood(moodName): return (moodName in ('happy','sad','ok'))
5,045
def checkMood(moodName): return (moodName in ('happy','sad','ok'))
def checkMood(moodName): return (moodName in ('happy','sad','ok'))
5,046
def checkMood(moodName): return (moodName in ('happy','sad','ok'))
def checkMood(moodName): return (moodName in ('happy','sad','ok'))
5,047
def func(x): W, H = _listWrapOn(self._content,x*availWidth,self.canv) W /= x H /= x return W, H
def func(x): W, H = _listWrapOn(self._content,x*availWidth,self.canv) W /= x H /= x return W, H
5,048
def func(x): W, H = _listWrapOn(self._content,x*availWidth,self.canv) W /= x H /= x return W, H
def func(x): W, H = _listWrapOn(self._content,x*availWidth,self.canv) W /= x H /= x return W, H
5,049
def func(x): W, H = _listWrapOn(self._content,x*availWidth,self.canv) W /= x H /= x return W, H
def func(x): W, H = _listWrapOn(self._content,x*availWidth,self.canv) W /= x H /= x return W, H
5,050
def func(x): W, H = _listWrapOn(self._content,x*availWidth,self.canv) W /= x H /= x return W, H
def func(x): W, H = _listWrapOn(self._content,x*availWidth,self.canv) W /= x H /= x return W, H
5,051
def func(x): W, H = _listWrapOn(self._content,x*availWidth,self.canv) W /= x H /= x return W, H
def func(x): W, H = _listWrapOn(self._content,x*availWidth,self.canv) W /= x H /= x return W, H
5,052
def makeInnerLines(self): # inner grid lines group = Group() if self.useLines == 1: if self.orientation == 'vertical': for x in xrange(self.x + self.delta0, self.x + self.width, self.delta): line = Line(x, self.y, x, self.y + self.height) line.strokeColor = self.strokeColor line.strokeWidth = self.strokeWidth group.add(line) elif self.orientation == 'horizontal': for y in xrange(self.y + self.delta0, self.y + self.height, self.delta): line = Line(self.x, y, self.x + self.width, y) line.strokeColor = self.strokeColor line.strokeWidth = self.strokeWidth group.add(line)
def makeInnerLines(self): # inner grid lines group = Group() if self.useLines == 1: if self.orientation == 'vertical': for x in frange(self.x + self.delta0, self.x + w, self.delta): line = Line(x, self.y, x, self.y + h) line.strokeColor = self.strokeColor line.strokeWidth = self.strokeWidth group.add(line) elif self.orientation == 'horizontal': for y in xrange(self.y + self.delta0, self.y + self.height, self.delta): line = Line(self.x, y, self.x + self.width, y) line.strokeColor = self.strokeColor line.strokeWidth = self.strokeWidth group.add(line)
5,053
def makeInnerLines(self): # inner grid lines group = Group() if self.useLines == 1: if self.orientation == 'vertical': for x in xrange(self.x + self.delta0, self.x + self.width, self.delta): line = Line(x, self.y, x, self.y + self.height) line.strokeColor = self.strokeColor line.strokeWidth = self.strokeWidth group.add(line) elif self.orientation == 'horizontal': for y in xrange(self.y + self.delta0, self.y + self.height, self.delta): line = Line(self.x, y, self.x + self.width, y) line.strokeColor = self.strokeColor line.strokeWidth = self.strokeWidth group.add(line)
def makeInnerLines(self): # inner grid lines group = Group() if self.useLines == 1: if self.orientation == 'vertical': for x in xrange(self.x + self.delta0, self.x + self.width, self.delta): line = Line(x, self.y, x, self.y + self.height) line.strokeColor = self.strokeColor line.strokeWidth = self.strokeWidth group.add(line) if self.delta0 != 0: line = Line(self.x, self.y, self.x, self.y + h) line.strokeColor = self.strokeColor line.strokeWidth = self.strokeWidth group.add(line)
5,054
def makeInnerTiles(self): # inner grid lines group = Group()
def makeInnerTiles(self): # inner grid lines group = Group()
5,055
def makeInnerTiles(self): # inner grid lines group = Group()
def makeInnerTiles(self): # inner grid lines group = Group()
5,056
def makeInnerTiles(self): # inner grid lines group = Group()
def makeInnerTiles(self): # inner grid lines group = Group()
5,057
def makeInnerTiles(self): # inner grid lines group = Group()
def makeInnerTiles(self): # inner grid lines group = Group()
5,058
def makeInnerTiles(self): # inner grid lines group = Group()
def makeInnerTiles(self): # inner grid lines group = Group()
5,059
def makeInnerTiles(self): # inner grid lines group = Group()
def makeInnerTiles(self): # inner grid lines group = Group()
5,060
def makeInnerTiles(self): # inner grid lines group = Group()
def makeInnerTiles(self): # inner grid lines group = Group()
5,061
def makeInnerTiles(self): # inner grid lines group = Group()
def makeInnerTiles(self): # inner grid lines group = Group()
5,062
def makeInnerTiles(self): # inner grid lines group = Group()
def makeInnerTiles(self): # inner grid lines group = Group()
5,063
def makeInnerTiles(self): # inner grid lines group = Group()
def makeInnerTiles(self): # inner grid lines group = Group()
5,064
def __init__(self): self.x = 0 self.y = 0 self.width = 100 self.height = 100 self.orientation = 'vertical' self.numShades = 20.0 self.fillColorStart = colors.pink self.fillColorEnd = colors.black self.strokeColor = colors.black self.strokeWidth = 2
def __init__(self): self.x = 0 self.y = 0 self.width = 100 self.height = 100 self.orientation = 'vertical' self.numShades = 20 self.fillColorStart = colors.pink self.fillColorEnd = colors.black self.strokeColor = colors.black self.strokeWidth = 2
5,065
def draw(self): # general widget bits group = Group() rect = Rect(self.x, self.y, self.width, self.height) rect.strokeColor = self.strokeColor rect.strokeWidth = self.strokeWidth rect.fillColor = None group.add(rect)
def draw(self): # general widget bits group = Group() w, h = self.width, self.height rect = Rect(self.x, self.y, w, h) rect.strokeColor = self.strokeColor rect.strokeWidth = self.strokeWidth rect.fillColor = None group.add(rect)
5,066
def draw(self): # general widget bits group = Group() rect = Rect(self.x, self.y, self.width, self.height) rect.strokeColor = self.strokeColor rect.strokeWidth = self.strokeWidth rect.fillColor = None group.add(rect)
def draw(self): # general widget bits group = Group() rect = Rect(self.x, self.y, self.width, self.height) rect.strokeColor = self.strokeColor rect.strokeWidth = self.strokeWidth rect.fillColor = None group.add(rect)
5,067
def draw(self): # general widget bits group = Group() rect = Rect(self.x, self.y, self.width, self.height) rect.strokeColor = self.strokeColor rect.strokeWidth = self.strokeWidth rect.fillColor = None group.add(rect)
def draw(self): # general widget bits group = Group() rect = Rect(self.x, self.y, self.width, self.height) rect.strokeColor = self.strokeColor rect.strokeWidth = self.strokeWidth rect.fillColor = None group.add(rect)
5,068
def draw(self): # general widget bits group = Group() rect = Rect(self.x, self.y, self.width, self.height) rect.strokeColor = self.strokeColor rect.strokeWidth = self.strokeWidth rect.fillColor = None group.add(rect)
def draw(self): # general widget bits group = Group() rect = Rect(self.x, self.y, self.width, self.height) rect.strokeColor = self.strokeColor rect.strokeWidth = self.strokeWidth rect.fillColor = None group.add(rect)
5,069
def draw(self): # general widget bits group = Group() rect = Rect(self.x, self.y, self.width, self.height) rect.strokeColor = self.strokeColor rect.strokeWidth = self.strokeWidth rect.fillColor = None group.add(rect)
def draw(self): # general widget bits group = Group() rect = Rect(self.x, self.y, self.width, self.height) rect.strokeColor = self.strokeColor rect.strokeWidth = self.strokeWidth rect.fillColor = None group.add(rect)
5,070
def draw(self): # general widget bits group = Group() rect = Rect(self.x, self.y, self.width, self.height) rect.strokeColor = self.strokeColor rect.strokeWidth = self.strokeWidth rect.fillColor = None group.add(rect)
def draw(self): # general widget bits group = Group() rect = Rect(self.x, self.y, self.width, self.height) rect.strokeColor = self.strokeColor rect.strokeWidth = self.strokeWidth rect.fillColor = None group.add(rect)
5,071
def test(): D = Drawing(450,650) g = Grid0() g.x = 20 g.y = 530 g.demo() D.add(g) g = Grid0() g.x = 140 g.y = 530 g.delta0 = 10 g.demo() D.add(g) g = Grid0() g.x = 260 g.y = 530 g.orientation = 'horizontal' g.demo() D.add(g) sr = ShadedRect0() sr.x = 20 sr.y = 390 sr.fillColorStart = colors.Color(0, 0, 0) sr.fillColorEnd = colors.Color(1, 1, 1) sr.demo() D.add(sr) sr = ShadedRect0() sr.x = 140 sr.y = 390 sr.fillColorStart = colors.Color(1, 1, 1) sr.fillColorEnd = colors.Color(0, 0, 0) sr.demo() D.add(sr) sr = ShadedRect0() sr.x = 20 sr.y = 250 sr.numShades = 10 sr.fillColorStart = colors.red sr.fillColorEnd = colors.blue sr.orientation = 'horizontal' sr.demo() D.add(sr) sr = ShadedRect0() sr.x = 140 sr.y = 250 sr.numShades = 20 sr.fillColorStart = colors.red sr.fillColorEnd = colors.blue sr.orientation = 'horizontal' sr.demo() D.add(sr) sr = ShadedRect0() sr.x = 260 sr.y = 250 sr.numShades = 50 sr.fillColorStart = colors.red sr.fillColorEnd = colors.blue sr.orientation = 'horizontal' sr.demo() D.add(sr) g = Grid0() g.x = 20 g.y = 110 g.useLines = 1 g.demo() D.add(g) g = Grid0() g.x = 140 g.y = 110 g.delta0 = 10 g.useLines = 1 g.useRects = 0 g.demo() D.add(g) g = Grid0() g.x = 260 g.y = 110 g.orientation = 'horizontal' g.useLines = 1 g.demo() D.add(g) renderPDF.drawToFile(D, 'grids.pdf', 'grids.py') print 'wrote file: grids.pdf'
def test(): D = Drawing(450,650) for row in range(5): y = 530 - row*120 if row == 0: for col in range(3): x = 20 + col*120 g = Grid0() g.x = x g.y = y g.useRects = 0 g.useLines = 1 if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 1: for col in range(3): x = 20 + col*120 g = Grid0() g.y = y g.x = x if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 2: for col in range(3): x = 20 + col*120 g = Grid0() g.x = x g.y = y g.useLines = 1 g.useRects = 1 if col == 0: pass elif col == 1: g.delta0 = 10 elif col == 2: g.orientation = 'horizontal' g.demo() D.add(g) elif row == 3: for col in range(3): x = 20 + col*120 sr = ShadedRect0() sr.x = x sr.y = y sr.fillColorStart = colors.Color(0, 0, 0) sr.fillColorEnd = colors.Color(1, 1, 1) if col == 0: sr.numShades = 5 elif col == 1: sr.numShades = 2 elif col == 2: sr.numShades = 1 sr.demo() D.add(sr) elif row == 4: for col in range(3): x = 20 + col*120 sr = ShadedRect0() sr.x = x sr.y = y sr.fillColorStart = colors.red sr.fillColorEnd = colors.blue sr.orientation = 'horizontal' if col == 0: sr.numShades = 10 elif col == 1: sr.numShades = 20 elif col == 2: sr.numShades = 50 sr.demo() D.add(sr) renderPDF.drawToFile(D, 'grids.pdf', 'grids.py') print 'wrote file: grids.pdf'
5,072
def _calc(self): H = self._rowHeights W = self._colWidths
def _calc(self): H = self._rowHeights W = self._colWidths
5,073
def test(): from reportlab.lib.units import inch rowheights = (24, 16, 16, 16, 16) rowheights2 = (24, 16, 16, 16, 30) colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32) data = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) data2 = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats\nLarge', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) styleSheet = getSampleStyleSheet() lst = [] lst.append(Paragraph("Tables", styleSheet['Heading1'])) lst.append(Paragraph(__doc__, styleSheet['BodyText'])) lst.append(Paragraph("The Tables (shown in different styles below) were created using the following code:", styleSheet['BodyText'])) lst.append(Preformatted(""" colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32) rowheights = (24, 16, 16, 16, 16) data = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) t = Table(colwidths, rowheights, data) """, styleSheet['Code'], dedent=4)) lst.append(Paragraph(""" You can then give the Table a TableStyle object to control its format. The first TableStyle used was created as follows: """, styleSheet['BodyText'])) lst.append(Preformatted("""
def test(): from reportlab.lib.units import inch rowheights = (24, 16, 16, 16, 16) rowheights2 = (24, 16, 16, 16, 30) colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32) data = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) data2 = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats\nLarge', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) styleSheet = getSampleStyleSheet() lst = [] lst.append(Paragraph("Tables", styleSheet['Heading1'])) lst.append(Paragraph(__doc__, styleSheet['BodyText'])) lst.append(Paragraph("The Tables (shown in different styles below) were created using the following code:", styleSheet['BodyText'])) lst.append(Preformatted(""" colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32) rowheights = (24, 16, 16, 16, 16) data = ( ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89), ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119), ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13), ('Hats', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843') ) t = Table(colwidths, rowheights, data) """, styleSheet['Code'], dedent=4)) lst.append(Paragraph(""" You can then give the Table a TableStyle object to control its format. The first TableStyle used was created as follows: """, styleSheet['BodyText'])) lst.append(Preformatted("""
5,074
def find_src_files(L,d,N): if string.upper(os.path.basename(d))=='CVS': return #ignore all CVS for n in N: fn = os.path.normcase(os.path.normpath(os.path.join(d,n))) if os.path.isfile(fn): L.append(fn)
def find_src_files(L,d,N): if string.upper(os.path.basename(d))=='CVS': return #ignore all CVS for n in N: fn = os.path.normcase(os.path.normpath(os.path.join(d,n))) if os.path.isfile(fn): L.append(fn)
5,075
def makeDocument(filename, pageCallBack=None): #the extra arg is a hack added later, so other #tests can get hold of the canvas just before it is #saved global titlelist, closeit titlelist = [] closeit = 0 c = canvas.Canvas(filename) c.setPageCompression(0) c.setPageCallBack(pageCallBack) framePageForm(c) # define the frame form c.showOutline() framePage(c, 'PDFgen graphics API test script') makesubsection(c, "PDFgen", 10*inch) t = c.beginText(inch, 10*inch) t.setFont('Times-Roman', 10) drawCrossHairs(c, t.getX(),t.getY()) t.textLines("""
def makeDocument(filename, pageCallBack=None): #the extra arg is a hack added later, so other #tests can get hold of the canvas just before it is #saved global titlelist, closeit titlelist = [] closeit = 0 c = canvas.Canvas(filename) c.setPageCompression(0) c.setPageCallBack(pageCallBack) framePageForm(c) # define the frame form c.showOutline() framePage(c, 'PDFgen graphics API test script') makesubsection(c, "PDFgen", 10*inch) t = c.beginText(inch, 10*inch) t.setFont('Times-Roman', 10) drawCrossHairs(c, t.getX(),t.getY()) t.textLines("""
5,076
def makeDocument(filename, pageCallBack=None): #the extra arg is a hack added later, so other #tests can get hold of the canvas just before it is #saved global titlelist, closeit titlelist = [] closeit = 0 c = canvas.Canvas(filename) c.setPageCompression(0) c.setPageCallBack(pageCallBack) framePageForm(c) # define the frame form c.showOutline() framePage(c, 'PDFgen graphics API test script') makesubsection(c, "PDFgen", 10*inch) t = c.beginText(inch, 10*inch) t.setFont('Times-Roman', 10) drawCrossHairs(c, t.getX(),t.getY()) t.textLines("""
def makeDocument(filename, pageCallBack=None): #the extra arg is a hack added later, so other #tests can get hold of the canvas just before it is #saved global titlelist, closeit titlelist = [] closeit = 0 c = canvas.Canvas(filename) c.setPageCompression(0) c.setPageCallBack(pageCallBack) framePageForm(c) # define the frame form c.showOutline() framePage(c, 'PDFgen graphics API test script') makesubsection(c, "PDFgen", 10*inch) t = c.beginText(inch, 10*inch) t.setFont('Times-Roman', 10) drawCrossHairs(c, t.getX(),t.getY()) t.textLines("""
5,077
def makeDocument(filename, pageCallBack=None): #the extra arg is a hack added later, so other #tests can get hold of the canvas just before it is #saved global titlelist, closeit titlelist = [] closeit = 0 c = canvas.Canvas(filename) c.setPageCompression(0) c.setPageCallBack(pageCallBack) framePageForm(c) # define the frame form c.showOutline() framePage(c, 'PDFgen graphics API test script') makesubsection(c, "PDFgen", 10*inch) t = c.beginText(inch, 10*inch) t.setFont('Times-Roman', 10) drawCrossHairs(c, t.getX(),t.getY()) t.textLines("""
def makeDocument(filename, pageCallBack=None): #the extra arg is a hack added later, so other #tests can get hold of the canvas just before it is #saved global titlelist, closeit titlelist = [] closeit = 0 c = canvas.Canvas(filename) c.setPageCompression(0) c.setPageCallBack(pageCallBack) framePageForm(c) # define the frame form c.showOutline() framePage(c, 'PDFgen graphics API test script') makesubsection(c, "PDFgen", 10*inch) t = c.beginText(inch, 10*inch) t.setFont('Times-Roman', 10) drawCrossHairs(c, t.getX(),t.getY()) t.textLines("""
5,078
def makeDocument(filename, pageCallBack=None): #the extra arg is a hack added later, so other #tests can get hold of the canvas just before it is #saved global titlelist, closeit titlelist = [] closeit = 0 c = canvas.Canvas(filename) c.setPageCompression(0) c.setPageCallBack(pageCallBack) framePageForm(c) # define the frame form c.showOutline() framePage(c, 'PDFgen graphics API test script') makesubsection(c, "PDFgen", 10*inch) t = c.beginText(inch, 10*inch) t.setFont('Times-Roman', 10) drawCrossHairs(c, t.getX(),t.getY()) t.textLines("""
def makeDocument(filename, pageCallBack=None): #the extra arg is a hack added later, so other #tests can get hold of the canvas just before it is #saved global titlelist, closeit titlelist = [] closeit = 0 c = canvas.Canvas(filename) c.setPageCompression(0) c.setPageCallBack(pageCallBack) framePageForm(c) # define the frame form c.showOutline() framePage(c, 'PDFgen graphics API test script') makesubsection(c, "PDFgen", 10*inch) t = c.beginText(inch, 10*inch) t.setFont('Times-Roman', 10) drawCrossHairs(c, t.getX(),t.getY()) t.textLines("""
5,079
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() # Triangle specific bits ae = s*0.125 #(ae = 'an eighth') triangle = shapes.Polygon(points = [ self.x, self.y, self.x+s, self.y, self.x+(s/2),self.y+s], fillColor = self.color, strokeColor = self.strokeColor, strokeWidth=s/50.) g.add(triangle) return g
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() # Triangle specific bits ae = s*0.125 #(ae = 'an eighth') triangle = shapes.Polygon(points = [ self.x, self.y, self.x+s, self.y, self.x+(s/2),self.y+s], fillColor = self.color, strokeColor = self.strokeColor, strokeWidth=s/50.) g.add(triangle) return g
5,080
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() # Triangle specific bits ae = s*0.125 #(ae = 'an eighth') triangle = shapes.Polygon(points = [ self.x, self.y, self.x+s, self.y, self.x,self.y+s], fillColor = self.color, strokeColor = self.strokeColor, strokeWidth=s/50.) g.add(triangle) return g
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() # Triangle specific bits ae = s*0.125 #(ae = 'an eighth') triangle = shapes.Polygon(points = [ self.x, self.y, self.x+s, self.y, self.x,self.y+s], fillColor = self.color, strokeColor = self.strokeColor, strokeWidth=s/50.) g.add(triangle) return g
5,081
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() # Octagon specific bits athird=s/3
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() # Octagon specific bits athird=s/3
5,082
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() # crossbox specific bits box = shapes.Rect(self.x+1, self.y+1, s-2, s-2, fillColor = None, strokeColor = self.boxColor, strokeWidth=2) g.add(box) crossLine1 = shapes.Line(self.x+(s*0.15), self.y+(s*0.15), self.x+(s*0.85), self.y+(s*0.85), fillColor = self.crossColor, strokeColor = self.crossColor, strokeWidth = self.crosswidth) g.add(crossLine1) crossLine2 = shapes.Line(self.x+(s*0.15), self.y+(s*0.85), self.x+(s*0.85) ,self.y+(s*0.15), fillColor = self.crossColor, strokeColor = self.crossColor, strokeWidth = self.crosswidth) g.add(crossLine2)
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() # crossbox specific bits box = shapes.Rect(self.x+1, self.y+1, s-2, s-2, fillColor = None, strokeColor = self.boxColor, strokeWidth=2) g.add(box) crossLine1 = shapes.Line(self.x+(s*0.15), self.y+(s*0.15), self.x+(s*0.85), self.y+(s*0.85), fillColor = self.crossColor, strokeColor = self.crossColor, strokeWidth = self.crosswidth) g.add(crossLine1) crossLine2 = shapes.Line(self.x+(s*0.15), self.y+(s*0.85), self.x+(s*0.85) ,self.y+(s*0.15), fillColor = self.crossColor, strokeColor = self.crossColor, strokeWidth = self.crosswidth) g.add(crossLine2)
5,083
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() # tickbox specific bits box = shapes.Rect(self.x+1, self.y+1, s-2, s-2, fillColor = None, strokeColor = self.boxColor, strokeWidth=2) g.add(box)
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() # tickbox specific bits box = shapes.Rect(self.x+1, self.y+1, s-2, s-2, fillColor = None, strokeColor = self.boxColor, strokeWidth=2) g.add(box)
5,084
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() # SmileyFace specific bits outerCircle = shapes.Circle(cx = (self.x+(s/2)), cy = (self.y+(s/2)), r = s/2, fillColor = self.color, strokeColor = colors.black, strokeWidth=s/38.) g.add(outerCircle)
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() # SmileyFace specific bits outerCircle = shapes.Circle(cx = (self.x+(s/2)), cy = (self.y+(s/2)), r = s/2, fillColor = self.color, strokeColor = colors.black, strokeWidth=s/38.) g.add(outerCircle)
5,085
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() # stop-sign specific bits athird=s/3
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() # stop-sign specific bits athird=s/3
5,086
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() # no-entry-sign specific bits outerCircle = shapes.Circle(cx = (self.x+(s/2)), cy = (self.y+(s/2)), r = s/2, fillColor = None, strokeColor = colors.black, strokeWidth=1) g.add(outerCircle)
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() # no-entry-sign specific bits outerCircle = shapes.Circle(cx = (self.x+(s/2)), cy = (self.y+(s/2)), r = s/2, fillColor = None, strokeColor = colors.black, strokeWidth=1) g.add(outerCircle)
5,087
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() # not=allowed specific bits outerCircle = shapes.Circle(cx = (self.x+(s/2)), cy = (self.y+(s/2)), r = (s/2)-(s/10), fillColor = None, strokeColor = colors.red, strokeWidth=s/10.) g.add(outerCircle) centerx=self.x+s centery=self.y+(s/2)-(s/6) radius=s-(s/6) yradius = radius/2 xradius = radius/2 startangledegrees=100 endangledegrees=-80 degreedelta = 90 pointslist = [] a = pointslist.append from math import sin, cos, pi degreestoradians = pi/180.0 radiansdelta = degreedelta*degreestoradians startangle = startangledegrees*degreestoradians endangle = endangledegrees*degreestoradians while endangle<startangle: endangle = endangle+2*pi angle = startangle while angle<endangle: x = centerx + cos(angle)*radius y = centery + sin(angle)*yradius a(x); a(y) angle = angle+radiansdelta crossbar = shapes.PolyLine(pointslist, fillColor = colors.red, strokeColor = colors.red, strokeWidth = s/10.)
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() # not=allowed specific bits outerCircle = shapes.Circle(cx = (self.x+(s/2)), cy = (self.y+(s/2)), r = (s/2)-(s/10), fillColor = None, strokeColor = colors.red, strokeWidth=s/10.) g.add(outerCircle) centerx=self.x+s centery=self.y+(s/2)-(s/6) radius=s-(s/6) yradius = radius/2 xradius = radius/2 startangledegrees=100 endangledegrees=-80 degreedelta = 90 pointslist = [] a = pointslist.append from math import sin, cos, pi degreestoradians = pi/180.0 radiansdelta = degreedelta*degreestoradians startangle = startangledegrees*degreestoradians endangle = endangledegrees*degreestoradians while endangle<startangle: endangle = endangle+2*pi angle = startangle while angle<endangle: x = centerx + cos(angle)*radius y = centery + sin(angle)*yradius a(x); a(y) angle = angle+radiansdelta crossbar = shapes.PolyLine(pointslist, fillColor = colors.red, strokeColor = colors.red, strokeWidth = s/10.)
5,088
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() # no-smoking-sign specific bits newx = self.x+(s/2)-(s/3.5) newy = self.y+(s/2)-(s/32) cigarrette1 = shapes.Rect(x = newx, y = newy, width = (s/2), height =(s/16), fillColor = colors.ghostwhite, strokeColor = colors.gray, strokeWidth=0) newx=newx+(s/2)+(s/64) g.add(cigarrette1) cigarrette2 = shapes.Rect(x = newx, y = newy, width = (s/80), height =(s/16), fillColor = colors.orangered, strokeColor = None, strokeWidth=0) newx= newx+(s/35) g.add(cigarrette2)
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() # no-smoking-sign specific bits newx = self.x+(s/2)-(s/3.5) newy = self.y+(s/2)-(s/32) cigarrette1 = shapes.Rect(x = newx, y = newy, width = (s/2), height =(s/16), fillColor = colors.ghostwhite, strokeColor = colors.gray, strokeWidth=0) newx=newx+(s/2)+(s/64) g.add(cigarrette1) cigarrette2 = shapes.Rect(x = newx, y = newy, width = (s/80), height =(s/16), fillColor = colors.orangered, strokeColor = None, strokeWidth=0) newx= newx+(s/35) g.add(cigarrette2)
5,089
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() ew = self.exmarkWidth ae = s*0.125 #(ae = 'an eighth')
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() ew = self.exmarkWidth ae = s*0.125 #(ae = 'an eighth')
5,090
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() ew = self.exmarkWidth ae = s*0.125 #(ae = 'an eighth')
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group() ew = self.exmarkWidth ae = s*0.125 #(ae = 'an eighth')
5,091
def demo(self): D = shapes.Drawing(200, 100) yn = YesNo0() yn.x = 15 yn.y = 25 yn.size = 70 yn.testValue = 0 yn.draw() D.add(yn) yn2 = YesNo0() yn2.x = 120 yn2.y = 25 yn2.size = 70 yn2.testValue = 1 yn2.draw() D.add(yn2) labelFontSize = 8 D.add(shapes.String(yn.x+(yn.size/2),(yn.y-(1.2*labelFontSize)), 'testValue=0', fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) D.add(shapes.String(yn2.x+(yn2.size/2),(yn2.y-(1.2*labelFontSize)), 'testValue=1', fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) labelFontSize = 10 D.add(shapes.String(yn.x+85,(yn.y-20), self.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) return D
def demo(self): D = shapes.Drawing(200, 100) yn = YesNo0() yn.x = 15 yn.y = 25 yn.size = 70 yn.testValue = 0 yn.draw() D.add(yn) yn2 = YesNo0() yn2.x = 120 yn2.y = 25 yn2.size = 70 yn2.testValue = 1 yn2.draw() D.add(yn2) labelFontSize = 8 D.add(shapes.String(yn.x+(yn.size/2),(yn.y-(1.2*labelFontSize)), 'testValue=0', fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) D.add(shapes.String(yn2.x+(yn2.size/2),(yn2.y-(1.2*labelFontSize)), 'testValue=1', fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) labelFontSize = 10 D.add(shapes.String(yn.x+85,(yn.y-20), self.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) return D
5,092
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group()
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group()
5,093
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group()
def draw(self): # general widget bits s = self.size # abbreviate as we will use this a lot g = shapes.Group()
5,094
def test(): """This function produces a pdf with examples of all the signs and symbols from this file. """ labelFontSize = 10 D = shapes.Drawing(450,650) cb = Crossbox0() cb.x = 20 cb.y = 530 cb.demo() D.add(cb) D.add(shapes.String(cb.x+(cb.size/2),(cb.y-(1.2*labelFontSize)), cb.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) tb = Tickbox0() tb.x = 170 tb.y = 530 tb.demo() D.add(tb) D.add(shapes.String(tb.x+(tb.size/2),(tb.y-(1.2*labelFontSize)), tb.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) yn = YesNo0() yn.x = 320 yn.y = 530 yn.demo() D.add(yn) tempstring = yn.__class__.__name__ + '*' D.add(shapes.String(yn.x+(tb.size/2),(yn.y-(1.2*labelFontSize)), tempstring, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) D.add(shapes.String(130,6, "(The 'YesNo' widget returns a tickbox if testvalue=1, and a crossbox if testvalue=0)", fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize*0.75)) ss = StopSign0() ss.x = 20 ss.y = 400 ss.demo() D.add(ss) D.add(shapes.String(ss.x+(ss.size/2), ss.y-(1.2*labelFontSize), ss.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) ne = NoEntry0() ne.x = 170 ne.y = 400 ne.demo() D.add(ne) D.add(shapes.String(ne.x+(ne.size/2),(ne.y-(1.2*labelFontSize)), ne.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) sf = SmileyFace0() sf.x = 320 sf.y = 400 sf.demo() D.add(sf) D.add(shapes.String(sf.x+(sf.size/2),(sf.y-(1.2*labelFontSize)), sf.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) ds = DangerSign0() ds.x = 20 ds.y = 270 ds.demo() D.add(ds) D.add(shapes.String(ds.x+(ds.size/2),(ds.y-(1.2*labelFontSize)), ds.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) na = NotAllowed0() na.x = 170 na.y = 270 na.demo() D.add(na) D.add(shapes.String(na.x+(na.size/2),(na.y-(1.2*labelFontSize)), na.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) ns = NoSmoking0() ns.x = 320 ns.y = 270 ns.demo() D.add(ns) D.add(shapes.String(ns.x+(ns.size/2),(ns.y-(1.2*labelFontSize)), ns.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) a1 = ArrowOne0() a1.x = 20 a1.y = 140 a1.demo() D.add(a1) D.add(shapes.String(a1.x+(a1.size/2),(a1.y-(1.2*labelFontSize)), a1.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) a2 = ArrowTwo0() a2.x = 170 a2.y = 140 a2.demo() D.add(a2) D.add(shapes.String(a2.x+(a2.size/2),(a2.y-(1.2*labelFontSize)), a2.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) fd = FloppyDisk0() fd.x = 320 fd.y = 140 fd.demo() D.add(fd) D.add(shapes.String(fd.x+(fd.size/2),(fd.y-(1.2*labelFontSize)), fd.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) renderPDF.drawToFile(D, 'signsandsymbols.pdf', 'signsandsymbols.py') print 'wrote file: signsandsymbols.pdf'
def test(): """This function produces a pdf with examples of all the signs and symbols from this file. """ labelFontSize = 10 D = shapes.Drawing(450,650) cb = Crossbox0() cb.x = 20 cb.y = 530 cb.demo() D.add(cb) D.add(shapes.String(cb.x+(cb.size/2),(cb.y-(1.2*labelFontSize)), cb.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) tb = Tickbox0() tb.x = 170 tb.y = 530 tb.demo() D.add(tb) D.add(shapes.String(tb.x+(tb.size/2),(tb.y-(1.2*labelFontSize)), tb.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) yn = YesNo0() yn.x = 320 yn.y = 530 yn.demo() D.add(yn) tempstring = yn.__class__.__name__ + '*' D.add(shapes.String(yn.x+(tb.size/2),(yn.y-(1.2*labelFontSize)), tempstring, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) D.add(shapes.String(130,6, "(The 'YesNo' widget returns a tickbox if testvalue=1, and a crossbox if testvalue=0)", fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize*0.75)) ss = StopSign0() ss.x = 20 ss.y = 400 ss.demo() D.add(ss) D.add(shapes.String(ss.x+(ss.size/2), ss.y-(1.2*labelFontSize), ss.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) ne = NoEntry0() ne.x = 170 ne.y = 400 ne.demo() D.add(ne) D.add(shapes.String(ne.x+(ne.size/2),(ne.y-(1.2*labelFontSize)), ne.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) sf = SmileyFace0() sf.x = 320 sf.y = 400 sf.demo() D.add(sf) D.add(shapes.String(sf.x+(sf.size/2),(sf.y-(1.2*labelFontSize)), sf.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) ds = DangerSign0() ds.x = 20 ds.y = 270 ds.demo() D.add(ds) D.add(shapes.String(ds.x+(ds.size/2),(ds.y-(1.2*labelFontSize)), ds.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) na = NotAllowed0() na.x = 170 na.y = 270 na.demo() D.add(na) D.add(shapes.String(na.x+(na.size/2),(na.y-(1.2*labelFontSize)), na.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) ns = NoSmoking0() ns.x = 320 ns.y = 270 ns.demo() D.add(ns) D.add(shapes.String(ns.x+(ns.size/2),(ns.y-(1.2*labelFontSize)), ns.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) a1 = ArrowOne0() a1.x = 20 a1.y = 140 a1.demo() D.add(a1) D.add(shapes.String(a1.x+(a1.size/2),(a1.y-(1.2*labelFontSize)), a1.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) a2 = ArrowTwo0() a2.x = 170 a2.y = 140 a2.demo() D.add(a2) D.add(shapes.String(a2.x+(a2.size/2),(a2.y-(1.2*labelFontSize)), a2.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) fd = FloppyDisk0() fd.x = 320 fd.y = 140 fd.demo() D.add(fd) D.add(shapes.String(fd.x+(fd.size/2),(fd.y-(1.2*labelFontSize)), fd.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) renderPDF.drawToFile(D, 'signsandsymbols.pdf', 'signsandsymbols.py') print 'wrote file: signsandsymbols.pdf'
5,095
def test(): """This function produces a pdf with examples of all the signs and symbols from this file. """ labelFontSize = 10 D = shapes.Drawing(450,650) cb = Crossbox0() cb.x = 20 cb.y = 530 cb.demo() D.add(cb) D.add(shapes.String(cb.x+(cb.size/2),(cb.y-(1.2*labelFontSize)), cb.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) tb = Tickbox0() tb.x = 170 tb.y = 530 tb.demo() D.add(tb) D.add(shapes.String(tb.x+(tb.size/2),(tb.y-(1.2*labelFontSize)), tb.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) yn = YesNo0() yn.x = 320 yn.y = 530 yn.demo() D.add(yn) tempstring = yn.__class__.__name__ + '*' D.add(shapes.String(yn.x+(tb.size/2),(yn.y-(1.2*labelFontSize)), tempstring, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) D.add(shapes.String(130,6, "(The 'YesNo' widget returns a tickbox if testvalue=1, and a crossbox if testvalue=0)", fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize*0.75)) ss = StopSign0() ss.x = 20 ss.y = 400 ss.demo() D.add(ss) D.add(shapes.String(ss.x+(ss.size/2), ss.y-(1.2*labelFontSize), ss.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) ne = NoEntry0() ne.x = 170 ne.y = 400 ne.demo() D.add(ne) D.add(shapes.String(ne.x+(ne.size/2),(ne.y-(1.2*labelFontSize)), ne.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) sf = SmileyFace0() sf.x = 320 sf.y = 400 sf.demo() D.add(sf) D.add(shapes.String(sf.x+(sf.size/2),(sf.y-(1.2*labelFontSize)), sf.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) ds = DangerSign0() ds.x = 20 ds.y = 270 ds.demo() D.add(ds) D.add(shapes.String(ds.x+(ds.size/2),(ds.y-(1.2*labelFontSize)), ds.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) na = NotAllowed0() na.x = 170 na.y = 270 na.demo() D.add(na) D.add(shapes.String(na.x+(na.size/2),(na.y-(1.2*labelFontSize)), na.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) ns = NoSmoking0() ns.x = 320 ns.y = 270 ns.demo() D.add(ns) D.add(shapes.String(ns.x+(ns.size/2),(ns.y-(1.2*labelFontSize)), ns.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) a1 = ArrowOne0() a1.x = 20 a1.y = 140 a1.demo() D.add(a1) D.add(shapes.String(a1.x+(a1.size/2),(a1.y-(1.2*labelFontSize)), a1.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) a2 = ArrowTwo0() a2.x = 170 a2.y = 140 a2.demo() D.add(a2) D.add(shapes.String(a2.x+(a2.size/2),(a2.y-(1.2*labelFontSize)), a2.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) fd = FloppyDisk0() fd.x = 320 fd.y = 140 fd.demo() D.add(fd) D.add(shapes.String(fd.x+(fd.size/2),(fd.y-(1.2*labelFontSize)), fd.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) renderPDF.drawToFile(D, 'signsandsymbols.pdf', 'signsandsymbols.py') print 'wrote file: signsandsymbols.pdf'
def test(): """This function produces a pdf with examples of all the signs and symbols from this file. """ labelFontSize = 10 D = shapes.Drawing(450,650) cb = Crossbox0() cb.x = 20 cb.y = 530 cb.demo() D.add(cb) D.add(shapes.String(cb.x+(cb.size/2),(cb.y-(1.2*labelFontSize)), cb.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) tb = Tickbox0() tb.x = 170 tb.y = 530 tb.demo() D.add(tb) D.add(shapes.String(tb.x+(tb.size/2),(tb.y-(1.2*labelFontSize)), tb.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) yn = YesNo0() yn.x = 320 yn.y = 530 yn.demo() D.add(yn) tempstring = yn.__class__.__name__ + '*' D.add(shapes.String(yn.x+(tb.size/2),(yn.y-(1.2*labelFontSize)), tempstring, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) D.add(shapes.String(130,6, "(The 'YesNo' widget returns a tickbox if testvalue=1, and a crossbox if testvalue=0)", fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize*0.75)) ss = StopSign0() ss.x = 20 ss.y = 400 ss.demo() D.add(ss) D.add(shapes.String(ss.x+(ss.size/2), ss.y-(1.2*labelFontSize), ss.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) ne = NoEntry0() ne.x = 170 ne.y = 400 ne.demo() D.add(ne) D.add(shapes.String(ne.x+(ne.size/2),(ne.y-(1.2*labelFontSize)), ne.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) sf = SmileyFace0() sf.x = 320 sf.y = 400 sf.demo() D.add(sf) D.add(shapes.String(sf.x+(sf.size/2),(sf.y-(1.2*labelFontSize)), sf.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) ds = DangerSign0() ds.x = 20 ds.y = 270 ds.demo() D.add(ds) D.add(shapes.String(ds.x+(ds.size/2),(ds.y-(1.2*labelFontSize)), ds.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) na = NotAllowed0() na.x = 170 na.y = 270 na.demo() D.add(na) D.add(shapes.String(na.x+(na.size/2),(na.y-(1.2*labelFontSize)), na.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) ns = NoSmoking0() ns.x = 320 ns.y = 270 ns.demo() D.add(ns) D.add(shapes.String(ns.x+(ns.size/2),(ns.y-(1.2*labelFontSize)), ns.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) a1 = ArrowOne0() a1.x = 20 a1.y = 140 a1.demo() D.add(a1) D.add(shapes.String(a1.x+(a1.size/2),(a1.y-(1.2*labelFontSize)), a1.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) a2 = ArrowTwo0() a2.x = 170 a2.y = 140 a2.demo() D.add(a2) D.add(shapes.String(a2.x+(a2.size/2),(a2.y-(1.2*labelFontSize)), a2.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) fd = FloppyDisk0() fd.x = 320 fd.y = 140 fd.demo() D.add(fd) D.add(shapes.String(fd.x+(fd.size/2),(fd.y-(1.2*labelFontSize)), fd.__class__.__name__, fillColor=colors.black, textAnchor='middle', fontSize=labelFontSize)) renderPDF.drawToFile(D, 'signsandsymbols.pdf', 'signsandsymbols.py') print 'wrote file: signsandsymbols.pdf'
5,096
def __setitem__(self, index, value): if self.vecttor[index]!=value: L = list(self.vector) L[index] = value self.vector = tuple(L)
def __setitem__(self, index, value): if self.vector[index]!=value: L = list(self.vector) L[index] = value self.vector = tuple(L)
5,097
def testMetrics(): # load the standard ones: for baseFontName in standardFonts: encoding = WinAnsiEncoding fontName = baseFontName + '-WinAnsi' font = Type1Font(fontName, baseFontName, encoding) addWidths(fontName, font.getWidths()) #test it msg = 'Hello World' w = stringWidth(msg, fontName, 10)# print 'width of "%s" in 10-point %s = %0.2f' % (msg, fontName, w)
def testMetrics(): # load the standard ones: for baseFontName in standardFonts: encoding = WinAnsiEncoding fontName = baseFontName + '-WinAnsi' font = Type1Font(fontName, baseFontName, encoding) #test it msg = 'Hello World' w = stringWidth(msg, fontName, 10)# print 'width of "%s" in 10-point %s = %0.2f' % (msg, fontName, w)
5,098
def testFonts(): # make a custom encoded font. import reportlab.pdfgen.canvas c = reportlab.pdfgen.canvas.Canvas('testfonts.pdf') c.setPageCompression(0) c.setFont('Helvetica', 12) c.drawString(100, 700, 'The text below should be in a custom encoding in which all vowels become "z"') # invent a new language where vowels are replaced with letter 'z' zenc = SingleByteEncoding('WinAnsiEncoding') for ch in 'aeiou': zenc[ord(ch)] = 'z' for ch in 'AEIOU': zenc[ord(ch)] = 'Z' f = Type1Font('FontWithoutVowels', 'Helvetica-Oblique', zenc) c.registerFont0(f) c.setFont('FontWithoutVowels', 12) c.drawString(125, 675, "The magic word is squamish ossifrage") # now demonstrate adding a Euro to MacRoman, which lacks one c.setFont('Helvetica', 12) c.drawString(100, 650, "MacRoman encoding lacks a Euro. We'll make a Mac font with the Euro at #219:") # WinAnsi Helvetica c.registerFont0(Type1Font('Helvetica-WinAnsi', 'Helvetica-Oblique', WinAnsiEncoding)) c.setFont('Helvetica-WinAnsi', 12) c.drawString(125, 625, 'WinAnsi with Euro: character 128 = "\200"') c.registerFont0(Type1Font('MacHelvNoEuro', 'Helvetica-Oblique', MacRomanEncoding)) c.setFont('MacHelvNoEuro', 12) c.drawString(125, 600, 'Standard MacRoman, no Euro: Character 219 = "\333"') # oct(219)=0333 # now make our hacked encoding euroMac = SingleByteEncoding('MacRomanEncoding') euroMac[219] = 'Euro' c.registerFont0(Type1Font('MacHelvWithEuro', 'Helvetica-Oblique', euroMac)) c.setFont('MacHelvWithEuro', 12) c.drawString(125, 575, 'Hacked MacRoman with Euro: Character 219 = "\333"') # oct(219)=0333 # now test width setting with and without _rl_accel - harder # make an encoding where 'm' becomes 'i' c.setFont('Helvetica', 12) c.drawString(100, 500, "Recode 'm' to 'i' and check we can measure widths. Boxes should surround letters.") sample = 'Mmmmm. ' * 6 + 'Mmmm' c.setFont('Helvetica-Oblique',12) c.drawString(125, 475, sample) w = c.stringWidth(sample, 'Helvetica-Oblique', 12) c.rect(125, 475, w, 12) narrowEnc = SingleByteEncoding('WinAnsiEncoding') narrowEnc[ord('m')] = 'i' narrowEnc[ord('M')] = 'I' c.registerFont0(Type1Font('narrow', 'Helvetica-Oblique', narrowEnc)) c.setFont('narrow', 12) c.drawString(125, 450, sample) w = c.stringWidth(sample, 'narrow', 12) c.rect(125, 450, w, 12) c.setFont('Helvetica', 12) c.drawString(100, 400, "Symbol & Dingbats fonts - check we still get valid PDF in StandardEncoding") c.setFont('Symbol', 12) c.drawString(100, 375, 'abcdefghijklmn') c.setFont('ZapfDingbats', 12) c.drawString(300, 375, 'abcdefghijklmn') c.save() print 'saved testfonts.pdf'
def testFonts(): # make a custom encoded font. import reportlab.pdfgen.canvas c = reportlab.pdfgen.canvas.Canvas('testfonts.pdf') c.setPageCompression(0) c.setFont('Helvetica', 12) c.drawString(100, 700, 'The text below should be in a custom encoding in which all vowels become "z"') # invent a new language where vowels are replaced with letter 'z' zenc = Encoding('WinAnsiEncoding') for ch in 'aeiou': zenc[ord(ch)] = 'z' for ch in 'AEIOU': zenc[ord(ch)] = 'Z' f = Type1Font('FontWithoutVowels', 'Helvetica-Oblique', zenc) c.registerFont0(f) c.setFont('FontWithoutVowels', 12) c.drawString(125, 675, "The magic word is squamish ossifrage") # now demonstrate adding a Euro to MacRoman, which lacks one c.setFont('Helvetica', 12) c.drawString(100, 650, "MacRoman encoding lacks a Euro. We'll make a Mac font with the Euro at #219:") # WinAnsi Helvetica c.registerFont0(Type1Font('Helvetica-WinAnsi', 'Helvetica-Oblique', WinAnsiEncoding)) c.setFont('Helvetica-WinAnsi', 12) c.drawString(125, 625, 'WinAnsi with Euro: character 128 = "\200"') c.registerFont0(Type1Font('MacHelvNoEuro', 'Helvetica-Oblique', MacRomanEncoding)) c.setFont('MacHelvNoEuro', 12) c.drawString(125, 600, 'Standard MacRoman, no Euro: Character 219 = "\333"') # oct(219)=0333 # now make our hacked encoding euroMac = SingleByteEncoding('MacRomanEncoding') euroMac[219] = 'Euro' c.registerFont0(Type1Font('MacHelvWithEuro', 'Helvetica-Oblique', euroMac)) c.setFont('MacHelvWithEuro', 12) c.drawString(125, 575, 'Hacked MacRoman with Euro: Character 219 = "\333"') # oct(219)=0333 # now test width setting with and without _rl_accel - harder # make an encoding where 'm' becomes 'i' c.setFont('Helvetica', 12) c.drawString(100, 500, "Recode 'm' to 'i' and check we can measure widths. Boxes should surround letters.") sample = 'Mmmmm. ' * 6 + 'Mmmm' c.setFont('Helvetica-Oblique',12) c.drawString(125, 475, sample) w = c.stringWidth(sample, 'Helvetica-Oblique', 12) c.rect(125, 475, w, 12) narrowEnc = SingleByteEncoding('WinAnsiEncoding') narrowEnc[ord('m')] = 'i' narrowEnc[ord('M')] = 'I' c.registerFont0(Type1Font('narrow', 'Helvetica-Oblique', narrowEnc)) c.setFont('narrow', 12) c.drawString(125, 450, sample) w = c.stringWidth(sample, 'narrow', 12) c.rect(125, 450, w, 12) c.setFont('Helvetica', 12) c.drawString(100, 400, "Symbol & Dingbats fonts - check we still get valid PDF in StandardEncoding") c.setFont('Symbol', 12) c.drawString(100, 375, 'abcdefghijklmn') c.setFont('ZapfDingbats', 12) c.drawString(300, 375, 'abcdefghijklmn') c.save() print 'saved testfonts.pdf'
5,099