Table Elements
| H |
The TABLE, TR, and TD classes all work together. The main attributes are specified to the TABLE constructor, which has the following keyword arguments:
- attrs
- The attributes for the <table> tag, as a dictionary.
- row_attrs and row_loop_start
- A list of attributes for the <tr> tags. The first list element is applied to the first row, the second to the second row, and so on. When the end of the list is reached, processing goes back to the list element with index row_loop_start. See below for an example.
- col_attrs and col_loop_start
- Like row_attrs, but apply to sequential <td> tags instead.
- sub
- Any pre-specified suboutputs (not usually used).
As an example of the use of this class, this Python code:
table = TABLE(
attrs = {'border' : 0, 'cellspacing' : 0 },
row_attrs = [ {'bgcolor' : '#808080'},
{'bgcolor' : '#FFFFFF'},
{'bgcolor' : '#EEEEEE'} ],
row_loop_start = 1,
col_attrs = [ { 'bgcolor' : '#808080' },
{ 'width' : '100' } ],
col_loop_start = 1)
table.append(TR( [ 'Foo', 'Bar', 'Bing', 'Baz' ] ) )
for i in range(10):
table.append(TR( [ 'foo-%d' % i, 'bar-%d' % i,
'bing-%d' % i, 'baz-%d' % i ] ) )
page.append(table)
made this table:
| Foo | Bar | Bing | Baz |
| foo-0 | bar-0 | bing-0 | baz-0 |
| foo-1 | bar-1 | bing-1 | baz-1 |
| foo-2 | bar-2 | bing-2 | baz-2 |
| foo-3 | bar-3 | bing-3 | baz-3 |
| foo-4 | bar-4 | bing-4 | baz-4 |
| foo-5 | bar-5 | bing-5 | baz-5 |
| foo-6 | bar-6 | bing-6 | baz-6 |
| foo-7 | bar-7 | bing-7 | baz-7 |
| foo-8 | bar-8 | bing-8 | baz-8 |
| foo-9 | bar-9 | bing-9 | baz-9 |

