equal
deleted
inserted
replaced
1 #copyright ReportLab Inc. 2000 |
1 #copyright ReportLab Inc. 2000 |
2 #see license.txt for license details |
2 #see license.txt for license details |
3 #history http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/reportlab/platypus/tables.py?cvsroot=reportlab |
3 #history http://cvs.sourceforge.net/cgi-bin/cvsweb.cgi/reportlab/platypus/tables.py?cvsroot=reportlab |
4 #$Header: /tmp/reportlab/reportlab/platypus/tables.py,v 1.45 2001/09/26 21:32:42 andy_robinson Exp $ |
4 #$Header: /tmp/reportlab/reportlab/platypus/tables.py,v 1.46 2001/11/23 17:53:30 rgbecker Exp $ |
5 __version__=''' $Id: tables.py,v 1.45 2001/09/26 21:32:42 andy_robinson Exp $ ''' |
5 __version__=''' $Id: tables.py,v 1.46 2001/11/23 17:53:30 rgbecker Exp $ ''' |
6 __doc__=""" |
6 __doc__=""" |
7 Tables are created by passing the constructor a tuple of column widths, a tuple of row heights and the data in |
7 Tables are created by passing the constructor a tuple of column widths, a tuple of row heights and the data in |
8 row order. Drawing of the table can be controlled by using a TableStyle instance. This allows control of the |
8 row order. Drawing of the table can be controlled by using a TableStyle instance. This allows control of the |
9 color and weight of the lines (if any), and the font, alignment and padding of the text. |
9 color and weight of the lines (if any), and the font, alignment and padding of the text. |
10 |
10 |
70 return result |
70 return result |
71 |
71 |
72 CellStyle = CellStyle1 |
72 CellStyle = CellStyle1 |
73 |
73 |
74 class TableStyle: |
74 class TableStyle: |
75 def __init__(self, cmds=None, parent=None): |
75 def __init__(self, cmds=None, parent=None, **kw): |
76 #handle inheritance from parent first. |
76 #handle inheritance from parent first. |
77 commands = [] |
77 commands = [] |
78 if parent: |
78 if parent: |
79 # copy the parents list at construction time |
79 # copy the parents list at construction time |
80 commands = commands + parent.getCommands() |
80 commands = commands + parent.getCommands() |
|
81 self._opts = parent._opts |
81 if cmds: |
82 if cmds: |
82 commands = commands + cmds |
83 commands = commands + cmds |
83 self._cmds = commands |
84 self._cmds = commands |
|
85 self._opts={} |
|
86 self._opts.update(kw) |
|
87 |
84 def add(self, *cmd): |
88 def add(self, *cmd): |
85 self._cmds.append(cmd) |
89 self._cmds.append(cmd) |
86 def __repr__(self): |
90 def __repr__(self): |
87 L = map(repr, self._cmds) |
91 L = map(repr, self._cmds) |
88 import string |
92 import string |
286 def setStyle(self, tblstyle): |
290 def setStyle(self, tblstyle): |
287 if type(tblstyle) is not TableStyleType: |
291 if type(tblstyle) is not TableStyleType: |
288 tblstyle = TableStyle(tblstyle) |
292 tblstyle = TableStyle(tblstyle) |
289 for cmd in tblstyle.getCommands(): |
293 for cmd in tblstyle.getCommands(): |
290 self._addCommand(cmd) |
294 self._addCommand(cmd) |
|
295 for k,v in tblstyle._opts.items(): |
|
296 setattr(self,k,v) |
291 |
297 |
292 def _addCommand(self,cmd): |
298 def _addCommand(self,cmd): |
293 if cmd[0] == 'BACKGROUND': |
299 if cmd[0] == 'BACKGROUND': |
294 self._bkgrndcmds.append(cmd) |
300 self._bkgrndcmds.append(cmd) |
295 elif _isLineCommand(cmd): |
301 elif _isLineCommand(cmd): |