reportlab/platypus/tables.py
changeset 342 a6982189331d
parent 338 f5eb86d4224f
child 350 0916ae478b25
equal deleted inserted replaced
341:27c68d524504 342:a6982189331d
    29 # OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
    29 # OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
    30 # PERFORMANCE OF THIS SOFTWARE. 
    30 # PERFORMANCE OF THIS SOFTWARE. 
    31 #
    31 #
    32 ###############################################################################
    32 ###############################################################################
    33 #	$Log: tables.py,v $
    33 #	$Log: tables.py,v $
       
    34 #	Revision 1.19  2000/07/10 15:25:47  andy_robinson
       
    35 #	Added tables to PythonPoint
       
    36 #
    34 #	Revision 1.18  2000/07/08 15:30:04  rgbecker
    37 #	Revision 1.18  2000/07/08 15:30:04  rgbecker
    35 #	Cosmetics and error testing
    38 #	Cosmetics and error testing
    36 #
    39 #	
    37 #	Revision 1.17  2000/07/07 16:22:10  rgbecker
    40 #	Revision 1.17  2000/07/07 16:22:10  rgbecker
    38 #	Fix auto hieght stuff
    41 #	Fix auto hieght stuff
    39 #	
    42 #	
    40 #	Revision 1.16  2000/07/07 10:23:36  rgbecker
    43 #	Revision 1.16  2000/07/07 10:23:36  rgbecker
    41 #	First attempt at VALIGN
    44 #	First attempt at VALIGN
    81 #	License text fixes
    84 #	License text fixes
    82 #	
    85 #	
    83 #	Revision 1.2  2000/02/15 15:47:09  rgbecker
    86 #	Revision 1.2  2000/02/15 15:47:09  rgbecker
    84 #	Added license, __version__ and Logi comment
    87 #	Added license, __version__ and Logi comment
    85 #	
    88 #	
    86 __version__=''' $Id: tables.py,v 1.18 2000/07/08 15:30:04 rgbecker Exp $ '''
    89 __version__=''' $Id: tables.py,v 1.19 2000/07/10 15:25:47 andy_robinson Exp $ '''
    87 __doc__="""
    90 __doc__="""
    88 Tables are created by passing the constructor a tuple of column widths, a tuple of row heights and the data in
    91 Tables are created by passing the constructor a tuple of column widths, a tuple of row heights and the data in
    89 row order. Drawing of the table can be controlled by using a TableStyle instance. This allows control of the
    92 row order. Drawing of the table can be controlled by using a TableStyle instance. This allows control of the
    90 color and weight of the lines (if any), and the font, alignment and padding of the text.
    93 color and weight of the lines (if any), and the font, alignment and padding of the text.
    91 
    94 
   133 		return self._cmds
   136 		return self._cmds
   134 
   137 
   135 TableStyleType = type(TableStyle())
   138 TableStyleType = type(TableStyle())
   136 		
   139 		
   137 class Table(Flowable):
   140 class Table(Flowable):
   138 	def __init__(self, colWidths, rowHeights, data):
   141 	def __init__(self, colWidths, rowHeights, data, style=None):
   139 		if not colWidths:
   142 		if not colWidths:
   140 			raise ValueError, "Table must have at least 1 column"
   143 			raise ValueError, "Table must have at least 1 column"
   141 		if not rowHeights:
   144 		if not rowHeights:
   142 			raise ValueError, "Table must have at least 1 row"
   145 			raise ValueError, "Table must have at least 1 row"
   143 		nrows = self._nrows = len(rowHeights)
   146 		nrows = self._nrows = len(rowHeights)
   155 		for i in range(nrows):
   158 		for i in range(nrows):
   156 			self._cellstyles[i] = [dflt]*ncols
   159 			self._cellstyles[i] = [dflt]*ncols
   157 		self._bkgrndcmds = []
   160 		self._bkgrndcmds = []
   158 		self._linecmds = []
   161 		self._linecmds = []
   159 		self._curweight = self._curcolor = self._curcellstyle = None
   162 		self._curweight = self._curcolor = self._curcellstyle = None
       
   163 
       
   164 		if style:
       
   165 			self.setStyle(style)
   160 
   166 
   161 	def _calc(self):
   167 	def _calc(self):
   162 		if hasattr(self,'_argH'):
   168 		if hasattr(self,'_argH'):
   163 			self._rowHeights = self._argH
   169 			self._rowHeights = self._argH
   164 			del self._argH
   170 			del self._argH