PyInvoice/pyinvoice/components.py

37 lines
1 KiB
Python
Raw Normal View History

2015-05-28 10:17:55 +00:00
from reportlab.platypus import Paragraph, Table, TableStyle, Flowable
2015-05-27 09:35:13 +00:00
from reportlab.lib.styles import ParagraphStyle, getSampleStyleSheet
from reportlab.lib import colors
class CodeSnippet(Paragraph):
style = ParagraphStyle(
name='CodeSnippet',
parent=getSampleStyleSheet()['Code'],
backColor=colors.lightgrey, leftIndent=0,
borderPadding=(5, 5, 5, 5)
)
def __init__(self, code):
2015-05-27 17:09:44 +00:00
Paragraph.__init__(self, code, self.style)
2015-05-28 10:17:55 +00:00
class SimpleTable(Table):
style = TableStyle([
('INNERGRID', (0, 0), (-1, -1), .25, colors.black),
('BOX', (0, 0), (-1, -1), .25, colors.black),
])
2015-05-27 17:09:44 +00:00
def __init__(self, data, horizontal_align=None):
2015-05-28 10:17:55 +00:00
Table.__init__(self, data, style=self.style, hAlign=horizontal_align)
class PaidStamp(object):
def __init__(self, x, y):
self.x = x
self.y = y
def __call__(self, canvas, doc):
# TODO: xxx
canvas.saveState()
canvas.drawString(self.x, self.y, 'PAID')
canvas.restoreState()