本文整理汇总了Python中reportlab.platypus.Table.vAlign方法的典型用法代码示例。如果您正苦于以下问题:Python Table.vAlign方法的具体用法?Python Table.vAlign怎么用?Python Table.vAlign使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reportlab.platypus.Table
的用法示例。
在下文中一共展示了Table.vAlign方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import vAlign [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,
])
示例2: print_users
# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import vAlign [as 别名]
#.........这里部分代码省略.........
for id in idiomas:
idioma = Paragraph(id.Idioma, styleN)
nivelHablado = Paragraph(id.Nivel_hablado, styleN)
nivelEscrito = Paragraph(id.Nivel_escrito, styleN)
if cont == 0:
data= [[hIdioma, hNivelHablado, hNivelEscrito],
[idioma, nivelHablado, nivelEscrito]]
else:
data= [[idioma, nivelHablado, nivelEscrito]]
cont = 1
t = Table(data)
t.setStyle(TableStyle([
('INNERGRID', (0,0), (-1,-1), .75, colors.cornflowerblue),
('BOX', (0,0), (-1,-1), .75, colors.cornflowerblue),
]))
t.hAlign = 'CENTER'
elements.append(t)
##########################################################
elements.append(Paragraph('Capacitación', titulo))
# Headers
hTipoEvento = Paragraph('''<b>Tipo de Evento</b>''', styleBH)
hTipoCertificado = Paragraph('''<b>Tipo de Certificado</b>''', styleBH)
hNombreEvento = Paragraph('''<b>Nombre del Evento</b>''', styleBH)
hAreaEstudios = Paragraph('''<b>Area de Estudios</b>''', styleBH)
hHoras = Paragraph('''<b>Horas</b>''', styleBH)
cont = 0
capacitaciones = Capacitaciones.objects.filter(id_Empleado_id = idEmp)
for cap in capacitaciones:
tipEvento = Paragraph(cap.Tipo_Evento, styleN)
tipCertificado = Paragraph(cap.Tipo_Certificado, styleN)
nomEvento = Paragraph(cap.Nombre_Evento, styleN)
areaEstudios = Paragraph(cap.Area_Estudios, styleN)
horas = Paragraph(cap.Horas, styleN)
if cont == 0:
data= [[hTipoEvento, hTipoCertificado, hNombreEvento, hAreaEstudios, hHoras],
[tipEvento, tipCertificado, nomEvento, areaEstudios, horas]]
else:
data= [[tipEvento, tipCertificado, nomEvento, areaEstudios, horas]]
cont = 1
t = Table(data)
t.setStyle(TableStyle([
('INNERGRID', (0,0), (-1,-1), .75, colors.cornflowerblue),
('BOX', (0,0), (-1,-1), .75, colors.cornflowerblue),
('VALIGN',(0,0),(-1,-1),'CENTER'),
]))
t.hAlign = 'CENTER'
t.vAlign = 'CENTER'
elements.append(t)
##########################################################
elements.append(Paragraph('Referencias Personales', titulo))
# Headers
hNombres = Paragraph('''<b>Nombres</b>''', styleBH)
hApellidos = Paragraph('''<b>Apellidos</b>''', styleBH)
hTelefono = Paragraph('''<b>Teléfono</b>''', styleBH)
cont = 0
referencias = Referencias_Personales.objects.filter(id_Empleado_id = idEmp)
for ref in referencias:
nombres = Paragraph(ref.Nombres, styleN)
apellidos = Paragraph(ref.Apellidos, styleN)
telefono = Paragraph(ref.Telefono, styleN)
if cont == 0:
data= [[hNombres, hApellidos, hTelefono],
[nombres, apellidos, telefono]]
else:
data= [[nombres, apellidos, telefono]]
t = Table(data)
t.setStyle(TableStyle([
('INNERGRID', (0,0), (-1,-1), .75, colors.cornflowerblue),
('BOX', (0,0), (-1,-1), .75, colors.cornflowerblue),
]))
t.hAlign = 'CENTER'
if ref.Nombres != '' and ref.Apellidos != '' and cont == 0:
elements.append(t)
cont = 1
doc.build(elements)
# Get the value of the BytesIO buffer and write it to the response.
pdf = buffer.getvalue()
buffer.close()
return pdf
示例3: createDoc
# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import vAlign [as 别名]
#.........这里部分代码省略.........
if len(route) > 0:
route = str(route[0][0])
else:
route = '------'
try:
firstGS = str(int(float(row[73])))
except TypeError:
firstGS = '------'
try:
lastGS = str(int(float(row[74])))
except TypeError:
lastGS = '------'
msg_rcvd = calcMsgCount(row)
try:
firstVR = str(int(float(row[77])))
except TypeError:
firstVR = "------"
try:
lastVR = str(int(float(row[78])))
except TypeError:
lastVR = "------"
try:
firstTrk = str(int(float(row[79])))
except TypeError:
firstTrk = '----'
try:
lastTrk = str(int(float(row[80])))
except TypeError:
lastTrk = '----'
data.append(
[start_time, mode_s, callsign, country, manufacturer, firstSquawk, firstAlt, firstGS, firstVR, firstTrk,
msg_rcvd])
data.append([end_time, registration, route, owner, mfr_type, lastSquawk, lastAlt, lastGS, lastVR, lastTrk])
index += 1
if index % 2 == 0:
even_rows.append(index)
if row[28] == 1:
poi.append(index)
if str(row[6]).strip() == 'None':
chk.append(index)
# Reminder: (column, row) starting at 0
# (0,0) is upper left, (-1,-1) is lower right (row,0),(row,-1) is entire row
# t = Table(data, colWidths=colWidths, rowHeights=rowHeights, repeatRows=2)
t = Table(data, colWidths=colWidths, rowHeights=rowHeights, repeatRows=2, hAlign='LEFT')
t.hAlign = 'LEFT'
t.vAlign = 'CENTER'
# Define default table attributes
tblStyle = TableStyle([])
tblStyle.add('FONTSIZE', (0, 0), (-1, -1), page_font_size)
tblStyle.add('TEXTFONT', (0, 0), (-1, -1), page_font)
tblStyle.add('TEXTCOLOR', (0, 0), (-1, -1), colors.black)
tblStyle.add('TOPPADDING', (0, 0), (-1, -1), 6)
tblStyle.add('BOTTOMPADDING', (0, 0), (-1, -1), 0)
tblStyle.add('BOX', (0, 0), (-1, 1), .25, colors.black)
tblStyle.add('BOX', (0, 0), (-1, -1), 2, colors.black)
tblStyle.add('INNERGRID', (0, 0), (-1, 1), 0.15, colors.gray)
tblStyle.add('BACKGROUND', (0, 0), (-1, 1), colors.lightblue)
tblStyle.add('BACKGROUND', (0, 2), (-1, -1), colors.white)
for row in even_rows:
row1 = (row) * 2
row2 = row1 + 1
tblStyle.add('BACKGROUND', (0, row1), (-1, row2), colors.lightgreen)
if rptType == 'all':
for row in poi:
row1 = row * 2
row2 = row1 + 1
tblStyle.add('BACKGROUND', (0, row1), (-1, row1), colors.red)
tblStyle.add('BACKGROUND', (0, row2), (-1, row2), colors.red)
tblStyle.add('TEXTCOLOR', (0, row1), (-1, row1), colors.white)
tblStyle.add('TEXTCOLOR', (0, row2), (-1, row2), colors.white)
for row in chk:
row1 = row * 2
row2 = row1 + 1
tblStyle.add('BACKGROUND', (0, row1), (-1, row1), colors.yellow)
tblStyle.add('BACKGROUND', (0, row2), (-1, row2), colors.yellow)
tblStyle.add('TEXTCOLOR', (0, row1), (-1, row1), colors.black)
tblStyle.add('TEXTCOLOR', (0, row2), (-1, row2), colors.black)
t.setStyle(tblStyle)
elements.append(t)
# write the document to disk
doc.build(elements)