1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
# save in pdf file
fileName = 'pdfTable.pdf'
pdf = SimpleDocTemplate(
fileName,
pagesize=letter,
)
columns = [['verbe', 'infinitif','temps conjugaison']]
tableColumn = Table(columns)
tableP = Table(list(premierGroupe.values()))
# # add style
style = TableStyle([
('BACKGROUND', (0, 0), (3, 0), colors.green),
('TEXTCOLOR', (0, 0), (-1, 0), colors.whitesmoke),
('ALIGN', (0, 0), (-1, -1), 'CENTER'),
('FONTNAME', (0, 0), (-1, 0), 'Courier-Bold'),
('FONTSIZE', (0, 0), (-1, 0), 14),
('BOTTOMPADDING', (0, 0), (-1, 0), 12),
('BACKGROUND', (0, 1), (-1, -1), colors.beige),
])
tableColumn.setStyle(style)
tableP.setStyle(style)
ts = TableStyle(
[
('BOX', (0, 0), (-1, -1), 2, colors.black),
('LINEBEFORE', (2, 1), (2, -1), 2, colors.red),
('LINEABOVE', (0, 2), (-1, 2), 2, colors.green),
('GRID', (0, 1), (-1, -1), 2, colors.black),
]
)
tableColumn.setStyle(ts)
tableP.setStyle(ts)
# graphe premier groupes
plt.bar(frequencePG.keys(), frequencePG.values())
plt.xticks(rotation='vertical')
elems = []
elems.append(tableColumn)
elems.append(tableP)
pdf.build(elems) |
Partager