reportlab/platypus/tables.py
author aaron_watters
Tue, 13 Jun 2000 13:03:31 +0000
changeset 268 8414113fa500
parent 253 cfcf8d555a2c
child 312 b39b1a2ed9d5
permissions -rwxr-xr-x
more documentation changes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
     1
###############################################################################
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
     2
#
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
     3
#	ReportLab Public License Version 1.0
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
     4
#
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
     5
#   Except for the change of names the spirit and intention of this
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
     6
#   license is the same as that of Python
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
     7
#
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
     8
#	(C) Copyright ReportLab Inc. 1998-2000.
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
     9
#
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    10
#
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    11
# All Rights Reserved
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    12
#
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    13
# Permission to use, copy, modify, and distribute this software and its
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    14
# documentation for any purpose and without fee is hereby granted, provided
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    15
# that the above copyright notice appear in all copies and that both that
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    16
# copyright notice and this permission notice appear in supporting
7
ca9eb4f68eab License text fixes
rgbecker
parents: 6
diff changeset
    17
# documentation, and that the name of ReportLab not be used
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    18
# in advertising or publicity pertaining to distribution of the software
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    19
# without specific, written prior permission. 
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    20
# 
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    21
#
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    22
# Disclaimer
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    23
#
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    24
# ReportLab Inc. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    25
# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    26
# IN NO EVENT SHALL ReportLab BE LIABLE FOR ANY SPECIAL, INDIRECT
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    27
# OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    28
# OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    29
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    30
# PERFORMANCE OF THIS SOFTWARE. 
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    31
#
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    32
###############################################################################
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    33
#	$Log: tables.py,v $
268
8414113fa500 more documentation changes
aaron_watters
parents: 253
diff changeset
    34
#	Revision 1.12  2000/06/13 13:03:31  aaron_watters
8414113fa500 more documentation changes
aaron_watters
parents: 253
diff changeset
    35
#	more documentation changes
8414113fa500 more documentation changes
aaron_watters
parents: 253
diff changeset
    36
#
253
cfcf8d555a2c Platypus re-organisation
rgbecker
parents: 248
diff changeset
    37
#	Revision 1.11  2000/06/01 15:23:06  rgbecker
cfcf8d555a2c Platypus re-organisation
rgbecker
parents: 248
diff changeset
    38
#	Platypus re-organisation
268
8414113fa500 more documentation changes
aaron_watters
parents: 253
diff changeset
    39
#	
248
c103b7a55e79 Color fixes; thanks to J Alet
rgbecker
parents: 221
diff changeset
    40
#	Revision 1.10  2000/05/26 09:49:23  rgbecker
c103b7a55e79 Color fixes; thanks to J Alet
rgbecker
parents: 221
diff changeset
    41
#	Color fixes; thanks to J Alet
253
cfcf8d555a2c Platypus re-organisation
rgbecker
parents: 248
diff changeset
    42
#	
221
3d71b66b14c6 Changes related to removal of SimpleFlowDocument
rgbecker
parents: 168
diff changeset
    43
#	Revision 1.9  2000/05/16 16:15:16  rgbecker
3d71b66b14c6 Changes related to removal of SimpleFlowDocument
rgbecker
parents: 168
diff changeset
    44
#	Changes related to removal of SimpleFlowDocument
248
c103b7a55e79 Color fixes; thanks to J Alet
rgbecker
parents: 221
diff changeset
    45
#	
168
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
    46
#	Revision 1.8  2000/04/26 11:07:15  andy_robinson
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
    47
#	Tables changed to use reportlab.lib.colors instead of
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
    48
#	the six hard-coded color strings there previously.
221
3d71b66b14c6 Changes related to removal of SimpleFlowDocument
rgbecker
parents: 168
diff changeset
    49
#	
129
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
    50
#	Revision 1.7  2000/04/14 12:17:05  rgbecker
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
    51
#	Splitting layout.py
168
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
    52
#	
128
a0676f013314 Splitting layout.py
rgbecker
parents: 122
diff changeset
    53
#	Revision 1.6  2000/04/14 11:54:57  rgbecker
a0676f013314 Splitting layout.py
rgbecker
parents: 122
diff changeset
    54
#	Splitting layout.py
129
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
    55
#	
122
fd68411f49db Drawable ==> Flowable
rgbecker
parents: 16
diff changeset
    56
#	Revision 1.5  2000/04/14 08:56:20  rgbecker
fd68411f49db Drawable ==> Flowable
rgbecker
parents: 16
diff changeset
    57
#	Drawable ==> Flowable
128
a0676f013314 Splitting layout.py
rgbecker
parents: 122
diff changeset
    58
#	
16
f9c7525619fb Docstring & other fixes
rgbecker
parents: 7
diff changeset
    59
#	Revision 1.4  2000/02/17 02:09:05  rgbecker
f9c7525619fb Docstring & other fixes
rgbecker
parents: 7
diff changeset
    60
#	Docstring & other fixes
122
fd68411f49db Drawable ==> Flowable
rgbecker
parents: 16
diff changeset
    61
#	
7
ca9eb4f68eab License text fixes
rgbecker
parents: 6
diff changeset
    62
#	Revision 1.3  2000/02/15 17:55:59  rgbecker
ca9eb4f68eab License text fixes
rgbecker
parents: 6
diff changeset
    63
#	License text fixes
16
f9c7525619fb Docstring & other fixes
rgbecker
parents: 7
diff changeset
    64
#	
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    65
#	Revision 1.2  2000/02/15 15:47:09  rgbecker
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    66
#	Added license, __version__ and Logi comment
7
ca9eb4f68eab License text fixes
rgbecker
parents: 6
diff changeset
    67
#	
268
8414113fa500 more documentation changes
aaron_watters
parents: 253
diff changeset
    68
__version__=''' $Id: tables.py,v 1.12 2000/06/13 13:03:31 aaron_watters Exp $ '''
16
f9c7525619fb Docstring & other fixes
rgbecker
parents: 7
diff changeset
    69
__doc__="""
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    70
Tables are created by passing the constructor a tuple of column widths, a tuple of row heights and the data in
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    71
row order. Drawing of the table can be controlled by using a TableStyle instance. This allows control of the
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    72
color and weight of the lines (if any), and the font, alignment and padding of the text.
268
8414113fa500 more documentation changes
aaron_watters
parents: 253
diff changeset
    73
8414113fa500 more documentation changes
aaron_watters
parents: 253
diff changeset
    74
See the test output from running this module as a script for a discussion of the method for constructing
8414113fa500 more documentation changes
aaron_watters
parents: 253
diff changeset
    75
tables and table styles.
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    76
"""
253
cfcf8d555a2c Platypus re-organisation
rgbecker
parents: 248
diff changeset
    77
from reportlab.platypus import *
129
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
    78
from reportlab.lib.styles import PropertySet, getSampleStyleSheet
168
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
    79
from reportlab.lib import colors
253
cfcf8d555a2c Platypus re-organisation
rgbecker
parents: 248
diff changeset
    80
from reportlab.lib.pagesizes import DEFAULT_PAGE_SIZE
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    81
import operator
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    82
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    83
_stringtype = type('')
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    84
128
a0676f013314 Splitting layout.py
rgbecker
parents: 122
diff changeset
    85
class CellStyle(PropertySet):
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    86
    defaults = {
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    87
        'fontname':'Times-Roman',
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    88
        'fontsize':10,
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    89
        'leading':12,
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    90
        'leftPadding':6,
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    91
        'rightPadding':6,
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    92
        'topPadding':3,
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    93
        'bottomPadding':3,
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    94
        'firstLineIndent':0,
168
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
    95
        'color':colors.black,
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    96
        'alignment': 'LEFT',
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    97
        'background': (1,1,1),
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
    98
        }
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
    99
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   100
class TableStyle:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   101
    def __init__(self, cmds=None):
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   102
        self._cmds = cmds
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   103
        if cmds is None:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   104
            self._cmds = []
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   105
    def add(self, *cmd):
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   106
        self._cmds.append(cmd)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   107
    def getCommands(self):
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   108
        return self._cmds
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   109
        
221
3d71b66b14c6 Changes related to removal of SimpleFlowDocument
rgbecker
parents: 168
diff changeset
   110
class Table(Flowable):
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   111
    def __init__(self, colWidths, rowHeights, data):
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   112
        if not colWidths:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   113
            raise ValueError, "Table must have at least 1 column"
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   114
        if not rowHeights:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   115
            raise ValueError, "Table must have at least 1 row"
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   116
        nrows = self._nrows = len(rowHeights)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   117
        if len(data) != nrows:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   118
            raise ValueError, "Data error - %d rows in data but %d in grid" % (len(data), nrows)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   119
        ncols = self._ncols = len(colWidths)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   120
        for i in range(nrows):
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   121
            if len(data[i]) != ncols:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   122
                raise ValueError, "Not enough data points in row %d!" % i
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   123
        self._rowHeights = rowHeights
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   124
        self._colWidths = colWidths
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   125
        self._cellvalues = data
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   126
        dflt = CellStyle('<default>')
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   127
        self._cellstyles = [None]*nrows
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   128
        for i in range(nrows):
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   129
            self._cellstyles[i] = [dflt]*ncols
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   130
        self._bkgrndcmds = []
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   131
        self._linecmds = []
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   132
        height = self._height = reduce(operator.add, rowHeights, 0)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   133
        self._rowpositions = [height]    # index 0 is actually topline; we skip when processing cells
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   134
        for h in rowHeights:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   135
            height = height - h
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   136
            self._rowpositions.append(height)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   137
        assert height == 0
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   138
        width = 0
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   139
        self._colpositions = [0]        #index -1 is right side boundary; we skip when processing cells
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   140
        for w in colWidths:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   141
            width = width + w
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   142
            self._colpositions.append(width)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   143
        self._width = width
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   144
        self._curweight = self._curcolor = self._curcellstyle = None
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   145
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   146
    def setStyle(self, tblstyle):
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   147
        for cmd in tblstyle.getCommands():
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   148
            if cmd[0] == 'BACKGROUND':
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   149
                self._bkgrndcmds.append(cmd)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   150
            elif _isLineCommand(cmd):
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   151
                self._linecmds.append(cmd)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   152
            else:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   153
                (op, (sc, sr), (ec, er)), values = cmd[:3] , cmd[3:]
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   154
                if sc < 0: sc = sc + self._ncols
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   155
                if ec < 0: ec = ec + self._ncols
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   156
                if sr < 0: sr = sr + self._nrows
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   157
                if er < 0: er = er + self._nrows
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   158
                for i in range(sr, er+1):
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   159
                    for j in range(sc, ec+1):
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   160
                        _setCellStyle(self._cellstyles, i, j, op, values)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   161
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   162
    def _drawLines(self):
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   163
        for op, (sc, sr), (ec, er), weight, color in self._linecmds:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   164
            if sc < 0: sc = sc + self._ncols
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   165
            if ec < 0: ec = ec + self._ncols
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   166
            if sr < 0: sr = sr + self._nrows
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   167
            if er < 0: er = er + self._nrows
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   168
            if op == 'GRID':
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   169
                self._drawBox( (sc, sr), (ec, er), weight, color)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   170
                self._drawInnerGrid( (sc, sr), (ec, er), weight, color)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   171
            elif op in ('BOX',  'OUTLINE',):
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   172
                self._drawBox( (sc, sr), (ec, er), weight, color)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   173
            elif op == 'INNERGRID':
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   174
                self._drawInnerGrid( (sc, sr), (ec, er), weight, color)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   175
            elif op == 'LINEBELOW':
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   176
                self._drawHLines((sc, sr+1), (ec, er+1), weight, color)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   177
            elif op == 'LINEABOVE':
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   178
                self._drawHLines((sc, sr), (ec, er), weight, color)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   179
            elif op == 'LINEBEFORE':
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   180
                self._drawVLines((sc, sr), (ec, er), weight, color)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   181
            elif op == 'LINEAFTER':
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   182
                self._drawVLines((sc+1, sr), (ec+1, er), weight, color)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   183
            else:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   184
                raise ValueError, "Unknown line style %s" % op
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   185
        self._curcolor = None
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   186
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   187
    def _drawBox(self,  (sc, sr), (ec, er), weight, color):
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   188
        self._drawHLines((sc, sr), (ec, sr), weight, color)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   189
        self._drawHLines((sc, er+1), (ec, er+1), weight, color)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   190
        self._drawVLines((sc, sr), (sc, er), weight, color)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   191
        self._drawVLines((ec+1, sr), (ec+1, er), weight, color)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   192
    def _drawInnerGrid(self, (sc, sr), (ec, er), weight, color):
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   193
        self._drawHLines((sc, sr+1), (ec, er), weight, color)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   194
        self._drawVLines((sc+1, sr), (ec, er), weight, color)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   195
    def _prepLine(self, weight, color):
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   196
        if color != self._curcolor:
168
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   197
            self.canv.setStrokeColor(color)
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   198
            self._curcolor = color
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   199
        if weight != self._curweight:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   200
            self.canv.setLineWidth(weight)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   201
            self._curweight = weight
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   202
    def _drawHLines(self, (sc, sr), (ec, er), weight, color):
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   203
        self._prepLine(weight, color)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   204
        scp = self._colpositions[sc]
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   205
        ecp = self._colpositions[ec+1]
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   206
        for rowpos in self._rowpositions[sr:er+1]:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   207
            self.canv.line(scp, rowpos, ecp, rowpos)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   208
    def _drawVLines(self, (sc, sr), (ec, er), weight, color):
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   209
        self._prepLine(weight, color)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   210
        srp = self._rowpositions[sr]
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   211
        erp = self._rowpositions[er+1]
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   212
        for colpos in self._colpositions[sc:ec+1]:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   213
            self.canv.line(colpos, srp, colpos, erp)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   214
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   215
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   216
    def wrap(self, availWidth, availHeight):
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   217
        #nice and easy, since they are predetermined size
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   218
        self.availWidth = availWidth
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   219
        return (self._width, self._height)
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   220
                
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   221
    def draw(self):
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   222
        nudge = 0.5 * (self.availWidth - self._width)
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   223
        self.canv.translate(nudge, 0)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   224
        self._drawBkgrnd()
0
f19e0a2433ab Initial revision
gmcm
parents:
diff changeset
   225
        self._drawLines()
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   226
        for row, rowstyle, rowpos, rowheight in map(None, self._cellvalues, self._cellstyles, self._rowpositions[1:], self._rowHeights):
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   227
            for cellval, cellstyle, colpos, colwidth in map(None, row, rowstyle, self._colpositions[:-1], self._colWidths):
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   228
                self._drawCell(cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight))
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   229
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   230
    def _drawBkgrnd(self):
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   231
        for cmd, (sc, sr), (ec, er), color in self._bkgrndcmds:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   232
            if sc < 0: sc = sc + self._ncols
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   233
            if ec < 0: ec = ec + self._ncols
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   234
            if sr < 0: sr = sr + self._nrows
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   235
            if er < 0: er = er + self._nrows
248
c103b7a55e79 Color fixes; thanks to J Alet
rgbecker
parents: 221
diff changeset
   236
            color = colors.toColor(color, colors.Color(1,1,1))
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   237
            x0 = self._colpositions[sc]
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   238
            y0 = self._rowpositions[sr]
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   239
            x1 = self._colpositions[ec+1]
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   240
            y1 = self._rowpositions[er+1]
168
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   241
            self.canv.setFillColor(color)
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   242
            self.canv.rect(x0, y0, x1-x0, y1-y0,stroke=0,fill=1)
248
c103b7a55e79 Color fixes; thanks to J Alet
rgbecker
parents: 221
diff changeset
   243
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   244
    def _drawCell(self, cellval, cellstyle, (colpos, rowpos), (colwidth, rowheight)):
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   245
        #print "cellstyle is ", repr(cellstyle), id(cellstyle)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   246
        if self._curcellstyle is not cellstyle:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   247
            cur = self._curcellstyle
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   248
            if cur is None or cellstyle.color != cur.color:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   249
                #print "setting cell color to %s" % `cellstyle.color`
168
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   250
                self.canv.setFillColor(cellstyle.color)
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   251
            if cur is None or cellstyle.leading != cur.leading or cellstyle.fontname != cur.fontname or cellstyle.fontsize != cur.fontsize:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   252
                #print "setting font: %s, %s, %s" % (cellstyle.fontname, cellstyle.fontsize, cellstyle.leading)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   253
                self.canv.setFont(cellstyle.fontname, cellstyle.fontsize, cellstyle.leading)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   254
            self._curcellstyle = cellstyle
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   255
        just = cellstyle.alignment
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   256
        #print "alignment is ", just
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   257
        if just == 'LEFT':
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   258
            draw = self.canv.drawString
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   259
            x = colpos + cellstyle.leftPadding
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   260
        elif just in ('CENTRE', 'CENTER'):
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   261
            draw = self.canv.drawCentredString
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   262
            x = colpos + colwidth * 0.5
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   263
        else:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   264
            draw = self.canv.drawRightString
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   265
            x = colpos + colwidth - cellstyle.rightPadding
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   266
        y = rowpos + cellstyle.bottomPadding
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   267
        if type(cellval) is _stringtype:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   268
            val = cellval
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   269
        else:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   270
            val = str(cellval)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   271
        draw(x, y, val)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   272
        
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   273
# for text,
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   274
#   drawCentredString(self, x, y, text) where x is center
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   275
#   drawRightString(self, x, y, text) where x is right
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   276
#   drawString(self, x, y, text) where x is left
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   277
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   278
LINECOMMANDS = (
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   279
    'GRID', 'BOX', 'OUTLINE', 'INNERGRID', 'LINEBELOW', 'LINEABOVE', 'LINEBEFORE', 'LINEAFTER', )
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   280
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   281
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   282
def _isLineCommand(cmd):
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   283
    return cmd[0] in LINECOMMANDS
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   284
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   285
def _setCellStyle(cellstyles, i, j, op, values):
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   286
    new = CellStyle('<%d, %d>' % (i,j), cellstyles[i][j])
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   287
    cellstyles[i][j] = new
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   288
    if op == 'FONT':
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   289
        new.fontname = values[0]
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   290
        new.fontsize = values[1]
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   291
    elif op == 'TEXTCOLOR':
248
c103b7a55e79 Color fixes; thanks to J Alet
rgbecker
parents: 221
diff changeset
   292
        new.color = colors.toColor(values[0], colors.Color(0,0,0))
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   293
    elif op in ('ALIGN', 'ALIGNMENT'):
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   294
        new.alignment = values[0]
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   295
    elif op == 'LEFTPADDING':
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   296
        new.leftPadding = values[0]
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   297
    elif op == 'RIGHTPADDING':
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   298
        new.rightPadding = values[0]
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   299
    elif op == 'TOPPADDING':
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   300
        new.topPadding = values[0]
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   301
    elif op == 'BOTTOMPADDING':
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   302
        new.bottomPadding = values[0]
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   303
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   304
GRID_STYLE = TableStyle(
168
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   305
    [('GRID', (0,0), (-1,-1), 0.25, colors.black),
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   306
     ('ALIGN', (1,1), (-1,-1), 'RIGHT')]
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   307
    )
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   308
BOX_STYLE = TableStyle(
168
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   309
    [('BOX', (0,0), (-1,-1), 0.50, colors.black),
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   310
     ('ALIGN', (1,1), (-1,-1), 'RIGHT')]
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   311
    )
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   312
LABELED_GRID_STYLE = TableStyle(
168
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   313
    [('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   314
     ('BOX', (0,0), (-1,-1), 2, colors.black),
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   315
     ('LINEBELOW', (0,0), (-1,0), 2, colors.black),
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   316
     ('LINEAFTER', (0,0), (0,-1), 2, colors.black),
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   317
     ('ALIGN', (1,1), (-1,-1), 'RIGHT')]
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   318
    )
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   319
COLORED_GRID_STYLE = TableStyle(
168
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   320
    [('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   321
     ('BOX', (0,0), (-1,-1), 2, colors.red),
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   322
     ('LINEBELOW', (0,0), (-1,0), 2, colors.black),
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   323
     ('LINEAFTER', (0,0), (0,-1), 2, colors.black),
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   324
     ('ALIGN', (1,1), (-1,-1), 'RIGHT')]
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   325
    )
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   326
LIST_STYLE = TableStyle(
168
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   327
    [('LINEABOVE', (0,0), (-1,0), 2, colors.green),
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   328
     ('LINEABOVE', (0,1), (-1,-1), 0.25, colors.black),
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   329
     ('LINEBELOW', (0,-1), (-1,-1), 2, colors.green),
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   330
     ('ALIGN', (1,1), (-1,-1), 'RIGHT')]
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   331
    )
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   332
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   333
def test():
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   334
    rowheights = (24, 16, 16, 16, 16)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   335
    colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   336
    data = (
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   337
        ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'),
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   338
        ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89),
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   339
        ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119),
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   340
        ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13),
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   341
        ('Hats', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843')
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   342
        )
129
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
   343
    styleSheet = getSampleStyleSheet()
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   344
    lst = []
129
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
   345
    lst.append(Paragraph("Tables", styleSheet['Heading1']))
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
   346
    lst.append(Paragraph(__doc__, styleSheet['BodyText']))
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
   347
    lst.append(Paragraph("The Tables (shown in different styles below) were created using the following code:", styleSheet['BodyText']))
221
3d71b66b14c6 Changes related to removal of SimpleFlowDocument
rgbecker
parents: 168
diff changeset
   348
    lst.append(Preformatted("""
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   349
    colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   350
    rowheights = (24, 16, 16, 16, 16)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   351
    data = (
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   352
        ('', 'Jan', 'Feb', 'Mar','Apr','May', 'Jun',
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   353
           'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'),
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   354
        ('Mugs', 0, 4, 17, 3, 21, 47, 12, 33, 2, -2, 44, 89),
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   355
        ('T-Shirts', 0, 42, 9, -3, 16, 4, 72, 89, 3, 19, 32, 119),
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   356
        ('Key Ring', 0,0,0,0,0,0,1,0,0,0,2,13),
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   357
        ('Hats', 893, 912, '1,212', 643, 789, 159,
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   358
             888, '1,298', 832, 453, '1,344','2,843')
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   359
        )   
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   360
    t = Table(colwidths, rowheights,  data)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   361
    """, styleSheet['Code'], dedent=4))
129
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
   362
    lst.append(Paragraph("""
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   363
    You can then give the Table a TableStyle object to control its format. The first TableStyle used was
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   364
    created as follows:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   365
    """, styleSheet['BodyText']))
221
3d71b66b14c6 Changes related to removal of SimpleFlowDocument
rgbecker
parents: 168
diff changeset
   366
    lst.append(Preformatted("""
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   367
GRID_STYLE = TableStyle(
168
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   368
    [('GRID', (0,0), (-1,-1), 0.25, colors.black),
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   369
     ('ALIGN', (1,1), (-1,-1), 'RIGHT')]
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   370
    )
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   371
    """, styleSheet['Code']))
129
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
   372
    lst.append(Paragraph("""
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   373
    TableStyles are created by passing in a list of commands. There are two types of commands - line commands
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   374
    and cell formatting commands. In all cases, the first three elements of a command are the command name,
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   375
    the starting cell and the ending cell.
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   376
    """, styleSheet['BodyText']))
129
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
   377
    lst.append(Paragraph("""
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   378
    Line commands always follow this with the weight and color of the desired lines. Colors can be names,
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   379
    or they can be specified as a (R,G,B) tuple, where R, G and B are floats and (0,0,0) is black. The line
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   380
    command names are: GRID, BOX, OUTLINE, INNERGRID, LINEBELOW, LINEABOVE, LINEBEFORE
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   381
    and LINEAFTER. BOX and OUTLINE are equivalent, and GRID is the equivalent of applying both BOX and
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   382
    INNERGRID.
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   383
    """, styleSheet['BodyText']))
129
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
   384
    lst.append(Paragraph("""
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   385
    Cell formatting commands are:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   386
    """, styleSheet['BodyText']))
129
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
   387
    lst.append(Paragraph("""
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   388
    FONT - takes fontname, fontsize and (optional) leading.
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   389
    """, styleSheet['Definition']))
129
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
   390
    lst.append(Paragraph("""
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   391
    TEXTCOLOR - takes a color name or (R,G,B) tuple.
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   392
    """, styleSheet['Definition']))
129
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
   393
    lst.append(Paragraph("""
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   394
    ALIGNMENT (or ALIGN) - takes one of LEFT, RIGHT and CENTRE (or CENTER).
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   395
    """, styleSheet['Definition']))
129
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
   396
    lst.append(Paragraph("""
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   397
    LEFTPADDING - defaults to 6.
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   398
    """, styleSheet['Definition']))
129
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
   399
    lst.append(Paragraph("""
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   400
    RIGHTPADDING - defaults to 6.
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   401
    """, styleSheet['Definition']))
129
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
   402
    lst.append(Paragraph("""
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   403
    BOTTOMPADDING - defaults to 3.
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   404
    """, styleSheet['Definition']))
129
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
   405
    lst.append(Paragraph("""
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   406
    A tablestyle is applied to a table by calling Table.setStyle(tablestyle).
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   407
    """, styleSheet['BodyText']))
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   408
    t = Table(colwidths, rowheights,  data)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   409
    t.setStyle(GRID_STYLE)
221
3d71b66b14c6 Changes related to removal of SimpleFlowDocument
rgbecker
parents: 168
diff changeset
   410
    lst.append(PageBreak())
129
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
   411
    lst.append(Paragraph("This is GRID_STYLE\n", styleSheet['BodyText']))
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   412
    lst.append(t)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   413
    
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   414
    t = Table(colwidths, rowheights,  data)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   415
    t.setStyle(BOX_STYLE)
129
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
   416
    lst.append(Paragraph("This is BOX_STYLE\n", styleSheet['BodyText']))
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   417
    lst.append(t)
129
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
   418
    lst.append(Paragraph("""
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   419
    It was created as follows:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   420
    """, styleSheet['BodyText']))
221
3d71b66b14c6 Changes related to removal of SimpleFlowDocument
rgbecker
parents: 168
diff changeset
   421
    lst.append(Preformatted("""
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   422
BOX_STYLE = TableStyle(
168
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   423
    [('BOX', (0,0), (-1,-1), 0.50, colors.black),
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   424
     ('ALIGN', (1,1), (-1,-1), 'RIGHT')]
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   425
    )
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   426
    """, styleSheet['Code']))
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   427
    
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   428
    t = Table(colwidths, rowheights,  data)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   429
    t.setStyle(LABELED_GRID_STYLE)
129
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
   430
    lst.append(Paragraph("This is LABELED_GRID_STYLE\n", styleSheet['BodyText']))
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   431
    lst.append(t)
129
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
   432
    lst.append(Paragraph("""
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   433
    It was created as follows:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   434
    """, styleSheet['BodyText']))
221
3d71b66b14c6 Changes related to removal of SimpleFlowDocument
rgbecker
parents: 168
diff changeset
   435
    lst.append(Preformatted("""
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   436
LABELED_GRID_STYLE = TableStyle(
168
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   437
    [('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   438
     ('BOX', (0,0), (-1,-1), 2, colors.black),
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   439
     ('LINEBELOW', (0,0), (-1,0), 2, colors.black),
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   440
     ('LINEAFTER', (0,0), (0,-1), 2, colors.black),
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   441
     ('ALIGN', (1,1), (-1,-1), 'RIGHT')]
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   442
    )
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   443
    """, styleSheet['Code']))
221
3d71b66b14c6 Changes related to removal of SimpleFlowDocument
rgbecker
parents: 168
diff changeset
   444
    lst.append(PageBreak())
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   445
    
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   446
    t = Table(colwidths, rowheights,  data)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   447
    t.setStyle(COLORED_GRID_STYLE)
129
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
   448
    lst.append(Paragraph("This is COLORED_GRID_STYLE\n", styleSheet['BodyText']))
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   449
    lst.append(t)
129
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
   450
    lst.append(Paragraph("""
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   451
    It was created as follows:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   452
    """, styleSheet['BodyText']))
221
3d71b66b14c6 Changes related to removal of SimpleFlowDocument
rgbecker
parents: 168
diff changeset
   453
    lst.append(Preformatted("""
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   454
COLORED_GRID_STYLE = TableStyle(
168
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   455
    [('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   456
     ('BOX', (0,0), (-1,-1), 2, colors.red),
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   457
     ('LINEBELOW', (0,0), (-1,0), 2, colors.black),
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   458
     ('LINEAFTER', (0,0), (0,-1), 2, colors.black),
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   459
     ('ALIGN', (1,1), (-1,-1), 'RIGHT')]
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   460
    )
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   461
    """, styleSheet['Code']))
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   462
    
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   463
    t = Table(colwidths, rowheights,  data)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   464
    t.setStyle(LIST_STYLE)
129
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
   465
    lst.append(Paragraph("This is LIST_STYLE\n", styleSheet['BodyText']))
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   466
    lst.append(t)
129
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
   467
    lst.append(Paragraph("""
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   468
    It was created as follows:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   469
    """, styleSheet['BodyText']))
221
3d71b66b14c6 Changes related to removal of SimpleFlowDocument
rgbecker
parents: 168
diff changeset
   470
    lst.append(Preformatted("""
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   471
LIST_STYLE = TableStyle(
168
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   472
    [('LINEABOVE', (0,0), (-1,0), 2, colors.green),
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   473
     ('LINEABOVE', (0,1), (-1,-1), 0.25, colors.black),
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   474
     ('LINEBELOW', (0,-1), (-1,-1), 2, colors.green),
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   475
     ('ALIGN', (1,1), (-1,-1), 'RIGHT')]
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   476
    )
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   477
    """, styleSheet['Code']))
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   478
   
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   479
    t = Table(colwidths, rowheights,  data)
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   480
    ts = TableStyle(
168
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   481
    [('LINEABOVE', (0,0), (-1,0), 2, colors.green),
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   482
     ('LINEABOVE', (0,1), (-1,-1), 0.25, colors.black),
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   483
     ('LINEBELOW', (0,-1), (-1,-1), 2, colors.green),
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   484
     ('ALIGN', (1,1), (-1,-1), 'RIGHT'),
168
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   485
     ('TEXTCOLOR', (0,1), (0,-1), colors.red),
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   486
     ('BACKGROUND', (0,0), (-1,0), colors.Color(0,0.7,0.7))]
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   487
    )
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   488
    t.setStyle(ts)
129
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
   489
    lst.append(Paragraph("This is a custom style\n", styleSheet['BodyText']))
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   490
    lst.append(t)
129
623baa767856 Splitting layout.py
rgbecker
parents: 128
diff changeset
   491
    lst.append(Paragraph("""
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   492
    It was created as follows:
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   493
    """, styleSheet['BodyText']))
221
3d71b66b14c6 Changes related to removal of SimpleFlowDocument
rgbecker
parents: 168
diff changeset
   494
    lst.append(Preformatted("""
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   495
   ts = TableStyle(
168
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   496
    [('LINEABOVE', (0,0), (-1,0), 2, colors.green),
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   497
     ('LINEABOVE', (0,1), (-1,-1), 0.25, colors.black),
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   498
     ('LINEBELOW', (0,-1), (-1,-1), 2, colors.green),
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   499
     ('ALIGN', (1,1), (-1,-1), 'RIGHT'),
168
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   500
     ('TEXTCOLOR', (0,1), (0,-1), colors.red),
02bac1346c69 Tables changed to use reportlab.lib.colors instead of
andy_robinson
parents: 129
diff changeset
   501
     ('BACKGROUND', (0,0), (-1,0), colors.Color(0,0.7,0.7))]
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   502
    )
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   503
    """, styleSheet['Code']))
253
cfcf8d555a2c Platypus re-organisation
rgbecker
parents: 248
diff changeset
   504
    SimpleDocTemplate('testtables.pdf', showBoundary=1).build(lst)
6
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   505
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   506
if __name__ == '__main__':
eb791971b252 Added license, __version__ and Logi comment
rgbecker
parents: 0
diff changeset
   507
    test()