本文整理汇总了Python中reportlab.platypus.Table.link_object方法的典型用法代码示例。如果您正苦于以下问题:Python Table.link_object方法的具体用法?Python Table.link_object怎么用?Python Table.link_object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reportlab.platypus.Table
的用法示例。
在下文中一共展示了Table.link_object方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: new_club
# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import link_object [as 别名]
def new_club(self, club):
"""
Add a club on a new page
:param club: Club to print
:type club: Club
"""
logging.debug("New club: " + club.nom)
if not self.story:
# For the first page
self.club = club
else:
self.story.append(NextPageTemplate(club))
self.story.append(PageBreak())
table_style = header_table_style["Club"]
table = Table([[club.nom]], [self.page_width], 2 * cm, style=table_style)
table.link_object = (club, club.nom)
self.story.append(table)
table_style = header_table_style["Content"]
for departemental in (True, False):
total = 0
if departemental:
competitions = [c for c in club.competitions if c.departemental() and c.competition_link is None]
self.story.append(Paragraph("Compétitions départementales", sHeading2))
bonus = self.bonus["Départemental"]
else:
competitions = [c for c in club.competitions if not c.departemental() and c.competition_link is None]
self.story.append(Paragraph("Compétitions régionales et plus", sHeading2))
bonus = self.bonus["Régional"]
table_data = [["Compétition", "Réunions", "Points"]]
for competition in sorted(competitions, key=lambda c: c.startdate):
description = [Paragraph("{} - {}".format(competition.date_str(), competition.titre()), sNormal)]
for c in competition.linked:
description.append(Paragraph("{} - {}".format(c.date_str(), c.titre()), sNormal))
row = [description, [], []]
for reunion in competition.reunions:
pts = reunion.points(club)
total += pts
row[1].append(Paragraph("<a href='#{}'>{}</a>".format(reunion.link(), reunion.titre), sNormal))
row[2].append(Paragraph("{} points".format(pts), sNormal))
table_data.append(row)
table = Table(table_data, [self.page_width * x for x in (0.70, 0.15, 0.15)], style=table_style)
self.story.append(table)
self.story.append(Paragraph("<br/>Total des points: {}".format(total), sNormal))
if total < 0:
self.story.append(Paragraph("Valeur du malus: {:.2f} €".format(total * 10), sNormal))
else:
self.story.append(Paragraph("Valeur du bonus (Estimation): {:.2f} €"
.format(total * bonus), sNormal))
示例2: competition_header
# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import link_object [as 别名]
def competition_header(self, competition):
"""
Add header for the competition
:param competition: New competition
:type competition: Competition
"""
if competition.departemental():
table_style = header_table_style["Départemental"]
else:
table_style = header_table_style["Régional"]
table_data = [[competition.titre()],
[competition.type],
[competition.date_str()]]
table = Table(table_data, [self.page_width], [cm, 0.5 * cm, 0.5 * cm], style=table_style)
table.link_object = (competition, competition.titre())
self.story.append(table)
self.story.append(Paragraph("Lien WebFFN: <a href='{}'>{}</a>"
.format(competition.weblink(), competition.weblink()), sNormal))