当前位置: 首页>>代码示例>>Python>>正文


Python Table.hAlign方法代码示例

本文整理汇总了Python中reportlab.platypus.Table.hAlign方法的典型用法代码示例。如果您正苦于以下问题:Python Table.hAlign方法的具体用法?Python Table.hAlign怎么用?Python Table.hAlign使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在reportlab.platypus.Table的用法示例。


在下文中一共展示了Table.hAlign方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: crea_pdf

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import hAlign [as 别名]
    def crea_pdf(self):
        data = [('settimana', 'codice', 'prodotto', 'cod_ean')]

        self.c.execute("SELECT settimana,prodotto,SUM(quantita),cod_ean "
                       "FROM ingredienti "
                       "WHERE settimana = %s "
                       "GROUP BY prodotto",
                       (self.settimana.get(),))
        for i in self.c:
            data.append(i)

        doc = SimpleDocTemplate("./table.pdf", pagesize=A4)

        parts = []
        table_with_style = Table(data, [1 * inch, 1.7 * inch, inch])
        table_with_style.hAlign = "LEFT"

        table_with_style.setStyle(TableStyle([
            ('FONT', (0, 0), (-1, -1), 'Helvetica'),
            ('FONT', (0, 0), (-1, 0), 'Helvetica-Bold'),
            ('FONTSIZE', (0, 0), (-1, -1), 8),
            ('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
            ('BOX', (0, 0), (-1, 0), 0.25, colors.green),
            ('ALIGN', (0, 0), (-1, 0), 'CENTER'),
        ]))

        parts.append(Spacer(1, 0.5 * inch))
        parts.append(table_with_style)
        doc.build(parts)
        if messagebox.askyesno('STAMPA', 'Vuoi stampare il pdf?'):
            win32api.ShellExecute(None, "print", "table.pdf", None, ".", 0)
开发者ID:AleLuzzi,项目名称:GestioneLaboratorio,代码行数:33,代码来源:report_cucina_note.py

示例2: setTableData

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import hAlign [as 别名]
    def setTableData(self, queryset, fields, title):
        
        self.data.append(Paragraph("%s" % title, self.styles['Heading3']))
        data = []
        header = False
        for row in queryset:
            if not header:
                data.append([f["name"] for f in fields])
                header = True
            ctx = Context({"object": row })
            values = [ Template(h["bit"]).render(ctx) for h in fields ]
            data.append(values)
        
        table = PDFTable(data,None,None,None,1)
        ts = [
            ('ALIGNMENT', (0,0), (-1,-1), 'LEFT'),
            ('LINEBELOW', (0,0), (-1,-0), 2, colors.black),            
            ('LINEBELOW', (0,1), (-1,-1), 0.8, colors.lightgrey),
            ('FONT', (0,0), (-1, -1), "Helvetica", 8),
            ('ROWBACKGROUNDS', (0,0), (-1, -1), [colors.whitesmoke, colors.white]),            
        ]
        if self.hasfooter is True:
            ts.append(('LINEABOVE', (0,-1), (-1,-1), 1, colors.red))
            ts.append(('LINEBELOW', (0,-1), (-1,-1), 2, colors.red))            
            ts.append(('LINEBELOW', (0,-1), (-1,-1), 0.8, colors.lightgrey))
            ts.append(('FONT', (0,-1), (-1, -1), "Helvetica", 8))
            
        table.setStyle(TableStyle(ts))

        table.hAlign = "LEFT"
        self.data.append(table)
开发者ID:ukanga,项目名称:mctc,代码行数:33,代码来源:report.py

示例3: build_index_Casse

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import hAlign [as 别名]
	def build_index_Casse(self, records, sito):
		styleSheet = getSampleStyleSheet()
		styNormal = styleSheet['Normal']
		styBackground = ParagraphStyle('background', parent=styNormal, backColor=colors.pink)
		styH3 = styleSheet['Heading3']
		data = self.datestrfdate()
		lst = []
		lst.append(Paragraph("<b>ELENCO CASSE</b><br/><b>Sito: %s <br/>Data: %s <br/>Ditta esecutrice: adArte snc, Rimini</b>" % (sito, data), styH3))

		table_data = []
		for i in range(len(records)):
			exp_index = CASSE_index_pdf_sheet(records[i])
			table_data.append(exp_index.getTable())

		styles = exp_index.makeStyles()
		colWidths=[60,150,100, 120]
		table_data_formatted = Table(table_data, colWidths, style=styles)
		table_data_formatted.hAlign = "LEFT"

		#table_data_formatted.setStyle(styles)

		lst.append(table_data_formatted)
		lst.append(Spacer(0,0))

		filename = ('%s%s%s') % (self.PDF_path, os.sep, 'elenco_casse.pdf')
		f = open(filename, "wb")

		doc = SimpleDocTemplate(f, pagesize=(21*cm, 29*cm), showBoundary=1)
		doc.build(lst, canvasmaker=NumberedCanvas_Campioniindex)

		f.close()
开发者ID:enzococca,项目名称:pyarchinit_beta_test_dev,代码行数:33,代码来源:pyarchinit_exp_Campsheet_pdf.py

示例4: buildTable

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import hAlign [as 别名]
def buildTable(data):
  doc = SimpleDocTemplate("MOOSE_requirements_tracability.pdf", pagesize=A4, rightMargin=30,leftMargin=30, topMargin=30,bottomMargin=18)
  doc.pagesize = landscape(A4)
  elements = []

  #Configure style and word wrap
  s = getSampleStyleSheet()
  s = s["BodyText"]
  s.wordWrap = 'CJK'

  pdf_data = [["Requirement", "Description", "Test Case(s)"]]

  #TODO: Need a numerical sort here
  keys = sorted(data.keys())

  for key in keys:
    data[key][2] = '\n'.join(data[key][2])
    pdf_data.append([Paragraph(cell, s) for cell in data[key]])


  # Build the Table and Style Information
  tableThatSplitsOverPages = Table(pdf_data, repeatRows=1)
  tableThatSplitsOverPages.hAlign = 'LEFT'
  tblStyle = TableStyle([('TEXTCOLOR',(0,0),(-1,-1),colors.black),
                         ('VALIGN',(0,0),(-1,-1),'TOP'),
                         ('LINEBELOW',(0,0),(-1,-1),1,colors.black),
                         ('INNERGRID', (0,0), (-1,-1),1,colors.black),
                         ('BOX',(0,0),(-1,-1),1,colors.black),
                         ('BOX',(0,0),(0,-1),1,colors.black)])
  tblStyle.add('BACKGROUND',(0,0),(-1,-1),colors.lightblue)
  tblStyle.add('BACKGROUND',(0,1),(-1,-1),colors.white)
  tableThatSplitsOverPages.setStyle(tblStyle)
  elements.append(tableThatSplitsOverPages)

  doc.build(elements)
开发者ID:bggaston,项目名称:moose,代码行数:37,代码来源:tracability_matrix.py

示例5: crea_pdf

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import hAlign [as 别名]
    def crea_pdf(self):
        titolo = "Dettagli lotto numero " + self.tree.parent(self.item) + " " + self.tree.item(self.item, 'text')
        styles = getSampleStyleSheet()
        styles.add(ParagraphStyle(name='Center', alignment=TA_CENTER))
        data = [('Taglio', 'Lotto Ingresso', 'Fornitore', 'Documento', 'Data Acquisto')]

        self.c.execute("SELECT DISTINCT prod_origine, lotto_acq,fornitore,documento,data_acq "
                       "FROM lotti_vendita  JOIN ingresso_merce "
                       "WHERE progressivo_ven = %s "
                       "AND lotti_vendita.lotto_acq = ingresso_merce.progressivo_acq",
                       (self.tree.parent(self.item),))
        for lista in self.c:
            data.append(lista)

        doc = SimpleDocTemplate("./traccia.pdf", pagesize=A4)

        parts = []
        table_with_style = Table(data, [1 * inch, 1.7 * inch, inch])
        table_with_style.hAlign = "LEFT"

        table_with_style.setStyle(TableStyle([
            ('FONT', (0, 0), (-1, -1), 'Helvetica'),
            ('FONT', (0, 0), (-1, 0), 'Helvetica-Bold'),
            ('FONTSIZE', (0, 0), (-1, -1), 8),
            ('INNERGRID', (0, 0), (-1, -1), 0.25, colors.black),
            ('BOX', (0, 0), (-1, 0), 0.25, colors.green),
            ('ALIGN', (0, 0), (-1, 0), 'CENTER'), ]))

        parts.append(Paragraph(titolo, styles["Center"]))
        parts.append(Spacer(1, 0.5 * inch))
        parts.append(table_with_style)
        doc.build(parts)
        if messagebox.askyesno('STAMPA', 'Vuoi stampare il pdf?'):
            win32api.ShellExecute(None, "print", "traccia.pdf", None, ".", 0)
开发者ID:AleLuzzi,项目名称:GestioneLaboratorio,代码行数:36,代码来源:lotti_vendita.py

示例6: setTableData

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import hAlign [as 别名]
    def setTableData(self, queryset, fields, title):        
        """
        set table data
        @var queryset: data
        @var fields: table column headings
        @var title: Table Heading
    """
        data = []
        header = False
        c = 0;
        #prepare the data
        for row in queryset:
            if not header:
                data.append([f["name"] for f in fields])
                header = True
            ctx = Context({"object": row })
            values = [ Template(h["bit"]).render(ctx) for h in fields ]
            data.append(values)
        
        table = PDFTable(data,None,None,None,1)
        #table rows n cols formatting
        ts = [
            ('ALIGNMENT', (0,0), (-1,-1), 'LEFT'),
            ('LINEBELOW', (0,0), (-1,-0), 2, colors.black),            
            ('LINEBELOW', (0,1), (-1,-1), 0.8, colors.lightgrey),
            ('FONT', (0,0), (-1, -1), "Times-Roman", self.fontSize),
            ('ROWBACKGROUNDS', (0,0), (-1, -1), [colors.whitesmoke, colors.white]),    
            ('LEFTPADDING', (0,0), (-1, -1), 1),
            ('RIGHTPADDING', (0,0), (-1, -1), 1),
            ('TOPPADDING', (0,0), (-1, -1), 1),
            ('BOTTOMPADDING', (0,0), (-1, -1), 1),        
        ]
        
        #last row formatting when required
        if self.hasfooter is True:
            ts.append(('LINEABOVE', (0,-1), (-1,-1), 1, colors.black))
            ts.append(('LINEBELOW', (0,-1), (-1,-1), 2, colors.black))
            ts.append(('LINEBELOW', (0,3), (-0,-0), 2, colors.green))             
            ts.append(('LINEBELOW', (0,-1), (-1,-1), 0.8, colors.lightgrey))
            ts.append(('FONT', (0,-1), (-1, -1), "Times-Roman", 7))
            
        table.setStyle(TableStyle(ts))

        table.hAlign = "LEFT"
        self.data.append(table)
        
        """
            The number of rows per page for two columns is about 90.
            using this information you can figure how many pages the
            table is going to overlap hence you place a header/subtitle
            in that position for it to be printed appropriately
        """
        c = len(queryset)/90
            
        if int(c)< c:
           c = int(c) + 1
               
           for i in range(c):
               self.headers.append(title)
开发者ID:eliane,项目名称:rapidsms,代码行数:61,代码来源:pdfreport.py

示例7: __type_prestation_secondrow

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import hAlign [as 别名]
 def __type_prestation_secondrow(self):
     typePresta_data = [[ self.__autreTypePresta_checkbox(), Paragraph(u"Autre prestatation (à préciser):"+self.__prestaType_precisions(), self.paragraph_style)],]
     typePresta_style = TableStyle([self.fontsize_style,('VALIGN',(1,0),(1,0),'MIDDLE')])
     colWidths=[25, 500]
     typePresta_table = Table(data=typePresta_data, style=typePresta_style, colWidths=colWidths)
     typePresta_table.spaceAfter = 20
     typePresta_table.hAlign = 0
     self.elements.append(typePresta_table)
开发者ID:cazino,项目名称:Formation,代码行数:10,代码来源:base_evenement.py

示例8: chwstatus_pdf

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import hAlign [as 别名]
def chwstatus_pdf(request):
    # this is again some quick and dirty sample code    
    elements = []
    styles = getSampleStyleSheet()
    styles['Title'].alignment = TA_LEFT
    styles['Title'].fontName = styles['Heading2'].fontName = "Helvetica"
    styles["Normal"].fontName = "Helvetica"
    styles["Normal"].fontSize = 10
    styles["Normal"].fontWeight = "BOLD"
        
    filename = mkstemp(".pdf")[-1]
    doc = SimpleDocTemplate(filename)

    elements.append(Paragraph("RapidResponse MVP Kenya: CHW Last 30 Days Perfomance Report", styles['Title']))
    
    clinics = Provider.objects.values('clinic').distinct()
    for clinic in clinics:
        queryset, fields = chwstatus_build_report(clinic["clinic"])
        c = Facility.objects.filter(id=clinic["clinic"])[0]
        elements.append(Paragraph("%s" % c.name, styles['Heading3']))
        data = []
        header = False
        for row in queryset:
            if not header:
                data.append([f["name"] for f in fields])
                header = True
            ctx = Context({"object": row })
            values = [ Template(h["bit"]).render(ctx) for h in fields ]
            data.append(values)
        
        table = PDFTable(data,None,None,None,1)
        table.setStyle(TableStyle([
            ('ALIGNMENT', (0,0), (-1,-1), 'LEFT'),
            ('LINEBELOW', (0,0), (-1,-0), 2, colors.black),            
            ('LINEBELOW', (0,1), (-1,-1), 0.8, colors.lightgrey),
            ('FONT', (0,0), (-1, -1), "Helvetica", 8),
            ('ROWBACKGROUNDS', (0,0), (-1, -1), [colors.whitesmoke, colors.white]),
        ]))
        table.hAlign = "LEFT"
        elements.append(table)
    '''ctable = PDFTable(cdata)
    ctable.setStyle(TableStyle([
        ('ALIGNMENT', (0,0), (-1,-1), 'LEFT'),
        ('FONT', (0,0), (-1, -1), "Helvetica", 8)
    ]))
    elements.append(ctable)
    '''
    #elements.append(Paragraph("Created: %s" % datetime.now().strftime("%d/%m/%Y"), styles["Normal"]))        
    #doc.pagesize = landscape(A4)
    doc.build(elements, onFirstPage=myFirstPage, onLaterPages=myLaterPages)

    response = HttpResponse(mimetype='application/pdf')
    response['Content-Disposition'] = "attachment; filename=%s" % filename
    response.write(open(filename).read())
    os.remove(filename)
    return response
开发者ID:ukanga,项目名称:mctc,代码行数:58,代码来源:general.py

示例9: addDefaultTable

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import hAlign [as 别名]
 def addDefaultTable(self,data):
     tblStyle = TableStyle([('TEXTCOLOR',(0,0),(-1,-1),black),
                  ('VALIGN',(0,0),(-1,-1),'TOP'),
                  ('INNERGRID',(0,0),(-1,-1),1,black),
                  ('BOX',(0,0),(-1,-1),1,black),
                  ('BACKGROUND',(0,0),(-1,0),lightblue)])
     t = Table(data,colWidths="*")
     t.hAlign = 'LEFT'
     t.setStyle(tblStyle)
     self.story.append(t)
开发者ID:ddfelts,项目名称:hawkAPI,代码行数:12,代码来源:hawkPdf.py

示例10: partab

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import hAlign [as 别名]
def partab(left,right,tabamt):
	data = [[left,right]]
	t = Table(data)
	t.hAlign = 'LEFT'
	t.setStyle(TableStyle([('LEFTPADDING',(0,0),(1,0),0)]))
	t.setStyle(TableStyle([('TOPPADDING',(0,0),(1,0),0)]))
	t.setStyle(TableStyle([('BOTTOMPADDING',(0,0),(1,0),0)]))
	t.setStyle(TableStyle([('ALIGN',(0,0),(1,0),'LEFT')]))
	t._argW[0]=tabamt
	return t	
开发者ID:codedcolors,项目名称:lflpdf,代码行数:12,代码来源:makesow.py

示例11: addTable

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import hAlign [as 别名]
 def addTable(datad):
     #al.debug("Adding data to table: " + str(datad))
     t = Table(datad, cols * [ hpitch * unit ], rows * [ vpitch * unit ])
     t.hAlign = "LEFT"
     t.setStyle(TableStyle([("VALIGN", (0,0), (-1,-1), "TOP")]))
     # If we have more than 8 labels vertically, use a smaller font
     if rows > 8:
         t.setStyle(TableStyle([("VALIGN", (0,0), (-1,-1), "TOP"),
                                ("FONTSIZE", (0,0), (-1,-1), 8)]))
     elements.append(t)
开发者ID:magul,项目名称:asm3,代码行数:12,代码来源:utils.py

示例12: render

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import hAlign [as 别名]
 def render(self):
     venue = [["\uf017", Paragraph(self.time, styles["xs-event"])],
              ["\uf041", Paragraph(self.venue_name, styles["xs-event"])],
              ["", Paragraph(self.place, styles["xs-event"])]]
     table = Table(venue, style=self.table_style, spaceAfter=8, colWidths=[8, None])
     table.hAlign = "LEFT"
     table.vAlign = "TOP"
     return KeepTogether([
         Paragraph(self.name, styles["xs-event-title"]),
         table,
         ])
开发者ID:12foo,项目名称:event-flyer-factory,代码行数:13,代码来源:layouts.py

示例13: FullLine

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import hAlign [as 别名]
    def FullLine(self, line, value):
        self.story.append(Spacer(0, .1 * inch))
        self.PGraph(line)

        result = Table([["", value]], colWidths = [inch*.2, inch*4])
        result.setStyle(
            TableStyle( [('LINEBELOW', (1, 0), (1, -1), 0.5, colors.black),
                         ('BOTTOMPADDING', (0,0), (0,-1), 0),
                         ('TOPPADDING', (0, 0), (0, -1), 5),
                         ]
                        ))
        result.hAlign = 'LEFT'
        self.story.append(result)
开发者ID:cc-archive,项目名称:scicom,代码行数:15,代码来源:letter.py

示例14: addTableIpSrc

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import hAlign [as 别名]
 def addTableIpSrc(self,ndata):
     data = [["Group","Ip Source","Count"]]
     for i in ndata:
          data.append([i["group_name"],i["ip_src"],i["ip_src_count"]])
     tblStyle = TableStyle([('TEXTCOLOR',(0,0),(-1,-1),black),
                  ('VALIGN',(0,0),(-1,-1),'TOP'),
                  ('BOX',(0,0),(-1,-1),1,black),
                  ('INNERGRID',(0,0),(-1,-1),1,black),
                  ('BACKGROUND',(0,0),(2,0),lightblue)])
     t = Table(data,colWidths="*")
     t.hAlign = 'LEFT'
     t.setStyle(tblStyle)
     self.story.append(t)
开发者ID:ddfelts,项目名称:hawkAPI,代码行数:15,代码来源:hawkPdf.py

示例15: __lc_abandon

# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import hAlign [as 别名]
 def __lc_abandon(self, typeEvenement):
     abandonPresta_data = [[self.__abandon_checkbox(typeEvenement), u"A ABANDONNE EN COURS DE PRESTATION A LA DATE DU: " + self.__abandon_date(typeEvenement)],
                           [None, Paragraph(u"<strong>Indiquer le motif: </strong>" + self.__abandon_motif(typeEvenement), self.paragraph_style) ]
                       ]
     colWidths = [25, 500]
     abandonPresta_style = TableStyle([('FONTSIZE', (1,0), (1,0), self.grandePolice),
                                   ('VALIGN',(1,0),(1,0),'TOP'),
                                   ('FONTSIZE', (1,1), (1,1), self.basePolice),
                                   ])
     abandonPresta = Table(abandonPresta_data, style=abandonPresta_style, colWidths=colWidths)
     abandonPresta.hAlign = 0
     abandonPresta.spaceAfter = 20
     self.elements.append(abandonPresta)
开发者ID:cazino,项目名称:Formation,代码行数:15,代码来源:base_evenement.py


注:本文中的reportlab.platypus.Table.hAlign方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。