本文整理汇总了Python中reportlab.platypus.Table._argW[x]方法的典型用法代码示例。如果您正苦于以下问题:Python Table._argW[x]方法的具体用法?Python Table._argW[x]怎么用?Python Table._argW[x]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类reportlab.platypus.Table
的用法示例。
在下文中一共展示了Table._argW[x]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_invoice
# 需要导入模块: from reportlab.platypus import Table [as 别名]
# 或者: from reportlab.platypus.Table import _argW[x] [as 别名]
def _create_invoice(invoice_buffer, invoice):
every_page_frame = Frame(PAGE_MARGIN, PAGE_MARGIN + 250, PAGE_WIDTH - 2 * PAGE_MARGIN,
PAGE_HEIGHT -430 , id='EveryPagesFrame',showBoundary=0)
remit_frame = Frame(PAGE_MARGIN, PAGE_MARGIN, PAGE_WIDTH - 2 * PAGE_MARGIN,
PAGE_HEIGHT - 600, id='RemitFrame',showBoundary=0)
every_page_template = PageTemplate(id='EveryPages', frames=[every_page_frame,remit_frame], onPage=_create_header)
doc = BaseDocTemplate(invoice_buffer, pageTemplates=[every_page_template], pagesize=A4)
# this is the only way to get data into the onPage callback function
doc.invoice = invoice
owner = invoice.owner
elements = []
#elements.append(Spacer(1, SECTION_BUFFER_HEIGHT * 5))
# Draw Products Table
invoice_table_style = TableStyle([
('VALIGN', (0, 0), (-1, -1), 'TOP'),
('GRID',(0, 0), (-1, -1),1, colors.black),
('ALIGN', (0, 0), (-1, -1), 'LEFT')
])
items = invoice.order.lines.all()
discounts = invoice.order.basket_discounts
data = [
['Item','Product', 'Quantity','Unit Price','GST', 'Amount']
]
val = 1
for item in items:
data.append(
[
val,
item.description,
item.quantity,
'${}'.format(item.line_price_before_discounts_excl_tax),
'${}'.format(item.line_price_before_discounts_incl_tax-item.line_price_before_discounts_excl_tax),
'${}'.format(item.line_price_before_discounts_incl_tax)
]
)
val += 1
# Discounts
data.append(
[
'',
'',
'',
'',
'',
''
]
)
for discount in discounts:
data.append(
[
'',
discount.offer,
'',
'',
'',
'-${}'.format(discount.amount)
]
)
val += 1
t= Table(
data,
style=invoice_table_style,
hAlign='LEFT'
)
t._argW[1] = 2.3 * inch
for x in range (2,6):
t._argW[x] = 1.2 * inch
elements.append(t)
elements.append(Spacer(1, SECTION_BUFFER_HEIGHT * 2))
# /Products Table
elements.append(Paragraph('Your application cannot be processed until payment is received.', styles['Left']))
elements.append(Spacer(1, SECTION_BUFFER_HEIGHT * 6))
# Remitttance Frame
elements.append(FrameBreak())
boundary = BrokenLine(PAGE_WIDTH - 2 * (PAGE_MARGIN *1.1))
elements.append(boundary)
elements.append(Spacer(1, SECTION_BUFFER_HEIGHT))
remittance = Remittance(HEADER_MARGIN,HEADER_MARGIN - 10,invoice)
elements.append(remittance)
#_create_remittance(invoice_buffer,doc)
doc.build(elements)
return invoice_buffer