本文整理汇总了Python中reportlab.platypus.Spacer方法的典型用法代码示例。如果您正苦于以下问题:Python platypus.Spacer方法的具体用法?Python platypus.Spacer怎么用?Python platypus.Spacer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reportlab.platypus
的用法示例。
在下文中一共展示了platypus.Spacer方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_img_table
# 需要导入模块: from reportlab import platypus [as 别名]
# 或者: from reportlab.platypus import Spacer [as 别名]
def create_img_table(self, dir):
item_tbl_data = []
item_tbl_row = []
for i, file in enumerate(os.listdir(dir)):
last_item = len(os.listdir(dir)) - 1
if ".png" in file:
img = Image(os.path.join(dir, file), inch, inch)
img_name = file.replace(".png", "")
if len(item_tbl_row) == 4:
item_tbl_data.append(item_tbl_row)
item_tbl_row = []
elif i == last_item:
item_tbl_data.append(item_tbl_row)
i_tbl = Table([[img], [Paragraph(img_name, ParagraphStyle("item name style", wordWrap='CJK'))]])
item_tbl_row.append(i_tbl)
if len(item_tbl_data) > 0:
item_tbl = Table(item_tbl_data, colWidths=125)
self.elements.append(item_tbl)
self.elements.append(Spacer(1, inch * 0.5))
示例2: get_cover_page
# 需要导入模块: from reportlab import platypus [as 别名]
# 或者: from reportlab.platypus import Spacer [as 别名]
def get_cover_page(self, report_id, recipient):
# title = f"{self.report_title} No.: {report_id}"
styles = getSampleStyleSheet()
headline_style = styles["Heading1"]
headline_style.alignment = TA_CENTER
headline_style.fontSize = 48
subtitle_style = styles["Heading2"]
subtitle_style.fontSize = 24
subtitle_style.leading = 26
subtitle_style.alignment = TA_CENTER
CoverPage = []
logo = os.path.join(settings.BASE_DIR, self.logo_path)
image = Image(logo, 3 * inch, 3 * inch)
CoverPage.append(image)
CoverPage.append(Spacer(1, 18))
CoverPage.append(Paragraph("CONFIDENTIAL", headline_style))
# paragraph = Paragraph(
# f"Intended for: {recipient}, Title IX Coordinator", subtitle_style)
# CoverPage.append(paragraph)
CoverPage.append(PageBreak())
return CoverPage
# entrypoints
示例3: add_paragraph
# 需要导入模块: from reportlab import platypus [as 别名]
# 或者: from reportlab.platypus import Spacer [as 别名]
def add_paragraph(self, text):
"Add a paragraph (represented as a string) to the letter: used by OfficialLetter.add_letter"
if text.startswith('||'):
# it's our table microformat
lines = text.split('\n')
cells = [line.split('|')[2:] for line in lines] # [2:] effectively strips the leading '||'
self.flowables.append(Table(cells, style=self.table_style))
else:
[self.flowables.append(Paragraph(line, self.content_style)) for line in text.split("\n")]
self.flowables.append(Spacer(1, self.line_height))
示例4: _contents
# 需要导入模块: from reportlab import platypus [as 别名]
# 或者: from reportlab.platypus import Spacer [as 别名]
def _contents(self, memo):
"""
Produce a list of Flowables to form the body of the memo
"""
contents = []
space_height = self.line_height
# the header block
contents.append(MemoHead(key='Attention', value=', '.join(self.to_addr_lines), bold=True))
contents.append(MemoHead(key='From', value=', '.join(self.from_name_lines)))
contents.append(MemoHead(key='Re', value=self.subject[0]))
for subjectline in self.subject[1:]:
contents.append(MemoHead(key='', value=subjectline))
contents.append(MemoHead(key='Date', value=self.date.strftime('%B %d, %Y').replace(' 0', ' ')))
contents.append(Spacer(1, 2*space_height))
# insert each paragraph
for f in self.flowables:
contents.append(f)
#contents.append(Spacer(1, space_height))
# the CC lines
if self.cc_lines:
data = []
for cc in self.cc_lines:
data.append(['', Paragraph(cc, self.content_style)])
cc = Paragraph('cc:', self.content_style)
data[0][0] = cc
cc_table = Table(data, colWidths=[0.3 * inch, 5 * inch])
cc_table.hAlign = "LEFT"
cc_table.setStyle(TableStyle(
[('LEFTPADDING', (0, 0), (-1, -1), 0),
('RIGHTPADDING', (0, 0), (-1, -1), 0),
('TOPPADDING', (0, 0), (-1, -1), 0),
('BOTTOMPADDING', (0, 0), (-1, -1), 0)]))
contents.append(cc_table)
return contents
示例5: add_summary
# 需要导入模块: from reportlab import platypus [as 别名]
# 或者: from reportlab.platypus import Spacer [as 别名]
def add_summary(self, summary_table=[]):
self.story.append(Spacer(1, 8*cm))
self.story.append(Paragraph("Sequencing Report", self.title_style))
style = self.normal_style
style.alignment = TA_CENTER
self.story.append(Paragraph("{}".format(self.tag), style))
self.story.append(Spacer(1, 4*cm))
summary_table_style = [('ALIGN',(0,0),(0,-1),'RIGHT'),
('ALIGN',(1,0),(1,-1),'LEFT')]
if len(summary_table):
self.story.append(Table(summary_table, style=summary_table_style))
self.story.append(Spacer(1, 1*cm))
self.story.append(Paragraph("Nanopype {}".format(self.version), style))
self.story.append(PageBreak())
示例6: add_section_flowcells
# 需要导入模块: from reportlab import platypus [as 别名]
# 或者: from reportlab.platypus import Spacer [as 别名]
def add_section_flowcells(self, runnames=[]):
self.story.append(Paragraph("{:d} Flow cells".format(self.get_section_number()), self.heading_style))
self.story.append(Spacer(1, 0))
table_data = [('{:3d}: '.format(i), runname) for i, runname in enumerate(runnames)]
table_style = [('FONTSIZE', (0,0), (-1, -1), 10),
('BOTTOMPADDING', (0,0), (-1,-1), 1),
('TOPPADDING', (0,0), (-1,-1), 1),
('VALIGN', (0,0), (-1,-1), 'MIDDLE')]
self.story.append(Table(table_data, style=table_style))
self.story.append(Spacer(1, 0.5*cm))
示例7: add_section_sequences
# 需要导入模块: from reportlab import platypus [as 别名]
# 或者: from reportlab.platypus import Spacer [as 别名]
def add_section_sequences(self, plots=[], stats=None):
section = self.get_section_number()
subsection = itertools.count(1)
if stats is not None:
self.story.append(Paragraph("{:d} Basecalling".format(section), self.heading_style))
self.story.append(Spacer(1, 0))
self.story.append(Paragraph("{:d}.{:d} Summary".format(section, next(subsection)), self.heading2_style))
#['Tag', 'Basecalling', 'Sum', 'Mean', 'Median', 'N50', 'Maximum']
header = ['', ''] + list(stats.columns.values[2:])
table_data = [header] + [[y if isinstance(y, str) else '{:.0f}'.format(y) for y in x] for x in stats.values]
table_style = [ ('FONTSIZE', (0,0), (-1, -1), 10),
('LINEABOVE', (0,1), (-1,1), 0.5, colors.black),
('LINEBEFORE', (2,0), (2,-1), 0.5, colors.black),
('ALIGN', (0,0), (1,-1), 'LEFT'),
('ALIGN', (2,0), (-1,-1), 'RIGHT')]
self.story.append(Table(table_data, style=table_style))
self.story.append(Spacer(1, 0))
for key, group in itertools.groupby(plots, lambda x : x[1].basecalling):
self.story.append(Paragraph('{:d}.{:d} {}:'.format(section, next(subsection), key.capitalize()), self.heading2_style))
for plot_file, plot_wildcards in sorted(list(group), key=lambda x : x[1].i):
im = svg2rlg(plot_file)
im = Image(im, width=im.width * self.plot_scale, height=im.height * self.plot_scale)
im.hAlign = 'CENTER'
self.story.append(im)
self.story.append(Spacer(1, 0))
self.story.append(Spacer(1, 0.5*cm))
示例8: add_section_alignments
# 需要导入模块: from reportlab import platypus [as 别名]
# 或者: from reportlab.platypus import Spacer [as 别名]
def add_section_alignments(self, counts=[], bases=[], identity=[], coverage=[]):
section = self.get_section_number()
subsection = itertools.count(1)
self.story.append(Paragraph("{:d} Alignments".format(section), self.heading_style))
self.story.append(Spacer(1, 0))
if bases:
self.story.append(Paragraph("{:d}.{:d} Mapped bases (primary alignments)".format(section, next(subsection)), self.heading2_style))
for b, label in bases:
im = svg2rlg(b)
im = Image(im, width=im.width * self.plot_scale, height=im.height * self.plot_scale)
im.hAlign = 'CENTER'
self.story.append(Paragraph(label, self.normal_style))
self.story.append(im)
self.story.append(Spacer(1, 0))
if counts:
self.story.append(Paragraph("{:d}.{:d} Mapped reads".format(section, next(subsection)), self.heading2_style))
for c, label in counts:
im = svg2rlg(c)
im = Image(im, width=im.width * self.plot_scale, height=im.height * self.plot_scale)
im.hAlign = 'CENTER'
self.story.append(Paragraph(label, self.normal_style))
self.story.append(im)
self.story.append(Spacer(1, 0))
if identity:
self.story.append(Paragraph("{:d}.{:d} Read identity (primary alignments, all aligners)".format(section, next(subsection)), self.heading2_style))
for b, label in identity:
im = svg2rlg(b)
im = Image(im, width=im.width * self.plot_scale, height=im.height * self.plot_scale)
im.hAlign = 'CENTER'
self.story.append(Paragraph(label, self.normal_style))
self.story.append(im)
self.story.append(Spacer(1, 0))
if coverage:
self.story.append(Paragraph("{:d}.{:d} Coverage".format(section, next(subsection)), self.heading2_style))
im = svg2rlg(coverage[0])
im = Image(im, width=im.width * self.plot_scale, height=im.height * self.plot_scale)
im.hAlign = 'CENTER'
self.story.append(im)
self.story.append(Spacer(1, 0))
self.story.append(Spacer(1, 0.5*cm))
示例9: add_section_methylation
# 需要导入模块: from reportlab import platypus [as 别名]
# 或者: from reportlab.platypus import Spacer [as 别名]
def add_section_methylation(self, coverage=[]):
section = self.get_section_number()
subsection = itertools.count(1)
self.story.append(Paragraph("{:d} Methylation".format(section), self.heading_style))
self.story.append(Spacer(1, 0))
if coverage:
self.story.append(Paragraph("{:d}.{:d} CpG coverage".format(section, next(subsection)), self.heading2_style))
for f, label in coverage:
im = svg2rlg(f)
im = Image(im, width=im.width * self.plot_scale, height=im.height * self.plot_scale)
im.hAlign = 'CENTER'
self.story.append(Paragraph(label, self.normal_style))
self.story.append(im)
self.story.append(Spacer(1, 0))
示例10: append_answers
# 需要导入模块: from reportlab import platypus [as 别名]
# 或者: from reportlab.platypus import Spacer [as 别名]
def append_answers(self, json_question, instance, sub_count):
elements = []
if instance.form_status == 0:
form_status = "Pending"
elif instance.form_status == 1:
form_status = "Rejected"
elif instance.form_status == 2:
form_status = "Flagged"
elif instance.form_status == 3:
form_status = "Approved"
sub_count += 1
elements.append(Spacer(0,10))
elements.append(Paragraph("Submision "+ str(sub_count), self.paragraphstyle))
elements.append(Paragraph("Status : "+form_status, self.paragraphstyle))
elements.append(Paragraph("Submitted By:"+instance.submitted_by.username, self.paragraphstyle))
elements.append(Paragraph("Submitted Date:"+str(instance.date), self.paragraphstyle))
elements.append(Spacer(0,10))
self.data = []
self.additional_data=[]
self.main_answer = instance.instance.json
question = json.loads(json_question)
self.parse_individual_questions(question['children'])
t1 = Table(self.data, colWidths=(60*mm, None))
t1.setStyle(self.ts1)
elements.append(t1)
elements.append(Spacer(0,10))
if self.additional_data:
elements.append(Paragraph("Full Answers", styles['Heading4']))
for items in self.additional_data:
for k,v in items.items():
elements.append(Paragraph(k + " : ", styles['Heading5']))
elements.append(Paragraph(v, self.paragraphstyle))
elements.append(Spacer(0,10))
return elements
示例11: _build_bottom_tip
# 需要导入模块: from reportlab import platypus [as 别名]
# 或者: from reportlab.platypus import Spacer [as 别名]
def _build_bottom_tip(self):
if self._bottom_tip:
self._story.append(Spacer(5, 5))
self._story.append(
Paragraph(
self._bottom_tip,
ParagraphStyle(
'BottomTip',
parent=self._defined_styles.get('Normal'),
alignment=self._bottom_tip_align
)
)
)
示例12: add_question
# 需要导入模块: from reportlab import platypus [as 别名]
# 或者: from reportlab.platypus import Spacer [as 别名]
def add_question(self, question):
self.pdf_elements.append(Paragraph(question, self.body_style))
self.pdf_elements.append(Spacer(1, 4))
示例13: add_answer_list
# 需要导入模块: from reportlab import platypus [as 别名]
# 或者: from reportlab.platypus import Spacer [as 别名]
def add_answer_list(self, answers):
for answer in answers:
self.pdf_elements.append(Paragraph(answer, self.notes_style))
self.pdf_elements.append(Spacer(1, 1))
示例14: cover_page
# 需要导入模块: from reportlab import platypus [as 别名]
# 或者: from reportlab.platypus import Spacer [as 别名]
def cover_page(self):
return [
Image(
os.path.join(settings.BASE_DIR, api.NotificationApi.logo_path),
3 * inch,
3 * inch,
),
Spacer(1, 18),
Paragraph("CONFIDENTIAL", self.headline_style),
Spacer(1, 30),
Spacer(1, 40),
Paragraph(self.title, self.subtitle_style),
Spacer(1, 40),
PageBreak(),
]