2 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
\r
3 <html><head><title>Python: module HTML</title>
\r
4 </head><body bgcolor="#f0f0f8">
\r
6 <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
\r
7 <tr bgcolor="#7799ee">
\r
8 <td valign=bottom> <br>
\r
9 <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>HTML</strong></big></big> (version 0.04, 2009-07-28)</font></td
\r
10 ><td align=right valign=bottom
\r
11 ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="html.py">html.py</a></font></td></tr></table>
\r
12 <p><tt>HTML.py - v0.04 2009-07-28 Philippe Lagadec<br>
\r
14 This module provides a few classes to easily generate HTML code such as tables<br>
\r
17 Project website: <a href="http://www.decalage.info/python/html">http://www.decalage.info/python/html</a><br>
\r
19 License: CeCILL (open-source GPL compatible), see source code for details.<br>
\r
20 <a href="http://www.cecill.info">http://www.cecill.info</a></tt></p>
\r
22 <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
\r
23 <tr bgcolor="#ee77aa">
\r
24 <td colspan=3 valign=bottom> <br>
\r
25 <font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
\r
27 <tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
\r
28 <td width="100%"><dl>
\r
29 <dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a>
\r
32 <dt><font face="helvetica, arial"><a href="HTML.html#List">List</a>
\r
33 </font></dt><dt><font face="helvetica, arial"><a href="HTML.html#Table">Table</a>
\r
34 </font></dt><dt><font face="helvetica, arial"><a href="HTML.html#TableCell">TableCell</a>
\r
35 </font></dt><dt><font face="helvetica, arial"><a href="HTML.html#TableRow">TableRow</a>
\r
40 <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
\r
41 <tr bgcolor="#ffc8d8">
\r
42 <td colspan=3 valign=bottom> <br>
\r
43 <font color="#000000" face="helvetica, arial"><a name="List">class <strong>List</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
\r
45 <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
\r
46 <td colspan=2><tt>a <a href="#List">List</a> <a href="__builtin__.html#object">object</a> is used to create an ordered or unordered list in HTML.<br>
\r
47 (UL/OL tag)<br>
\r
50 - lines: list, tuple or any iterable, containing one string for each line<br>
\r
51 - ordered: bool, choice between an ordered (OL) or unordered list (UL)<br>
\r
52 - attribs: dict, additional attributes for the OL/UL tag<br>
\r
54 Reference: <a href="http://www.w3.org/TR/html4/struct/lists.html">http://www.w3.org/TR/html4/struct/lists.html</a><br> </tt></td></tr>
\r
56 <td width="100%">Methods defined here:<br>
\r
57 <dl><dt><a name="List-__init__"><strong>__init__</strong></a>(self, lines<font color="#909090">=None</font>, ordered<font color="#909090">=False</font>, start<font color="#909090">=None</font>, attribs<font color="#909090">=None</font>)</dt><dd><tt><a href="#List">List</a> constructor</tt></dd></dl>
\r
59 <dl><dt><a name="List-__str__"><strong>__str__</strong></a>(self)</dt><dd><tt>return the HTML code for the list as a string</tt></dd></dl>
\r
62 Data descriptors defined here:<br>
\r
63 <dl><dt><strong>__dict__</strong></dt>
\r
64 <dd><tt>dictionary for instance variables (if defined)</tt></dd>
\r
66 <dl><dt><strong>__weakref__</strong></dt>
\r
67 <dd><tt>list of weak references to the object (if defined)</tt></dd>
\r
69 </td></tr></table> <p>
\r
70 <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
\r
71 <tr bgcolor="#ffc8d8">
\r
72 <td colspan=3 valign=bottom> <br>
\r
73 <font color="#000000" face="helvetica, arial"><a name="Table">class <strong>Table</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
\r
75 <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
\r
76 <td colspan=2><tt>a <a href="#Table">Table</a> <a href="__builtin__.html#object">object</a> is used to create a HTML table. (TABLE tag)<br>
\r
79 - rows: list, tuple or any iterable, containing one iterable or <a href="#TableRow">TableRow</a><br>
\r
80 <a href="__builtin__.html#object">object</a> for each row<br>
\r
81 - header_row: list, tuple or any iterable, containing the header row (optional)<br>
\r
82 - border: str or int, border width<br>
\r
83 - style: str, table style in CSS syntax (thin black borders by default)<br>
\r
84 - width: str, width of the table on the page<br>
\r
85 - attribs: dict, additional attributes for the TABLE tag<br>
\r
86 - col_width: list or tuple defining width for each column<br>
\r
87 - col_align: list or tuple defining horizontal alignment for each column<br>
\r
88 - col_char: list or tuple defining alignment character for each column<br>
\r
89 - col_charoff: list or tuple defining charoff attribute for each column<br>
\r
90 - col_valign: list or tuple defining vertical alignment for each column<br>
\r
91 - col_styles: list or tuple of HTML styles for each column<br>
\r
93 Reference: <a href="http://www.w3.org/TR/html4/struct/tables.html#h-11.2.1">http://www.w3.org/TR/html4/struct/tables.html#h-11.2.1</a><br> </tt></td></tr>
\r
95 <td width="100%">Methods defined here:<br>
\r
96 <dl><dt><a name="Table-__init__"><strong>__init__</strong></a>(self, rows<font color="#909090">=None</font>, border<font color="#909090">='1'</font>, style<font color="#909090">=None</font>, width<font color="#909090">=None</font>, cellspacing<font color="#909090">=None</font>, cellpadding<font color="#909090">=4</font>, attribs<font color="#909090">=None</font>, header_row<font color="#909090">=None</font>, col_width<font color="#909090">=None</font>, col_align<font color="#909090">=None</font>, col_valign<font color="#909090">=None</font>, col_char<font color="#909090">=None</font>, col_charoff<font color="#909090">=None</font>, col_styles<font color="#909090">=None</font>)</dt><dd><tt><a href="#TableCell">TableCell</a> constructor</tt></dd></dl>
\r
98 <dl><dt><a name="Table-__str__"><strong>__str__</strong></a>(self)</dt><dd><tt>return the HTML code for the table as a string</tt></dd></dl>
\r
101 Data descriptors defined here:<br>
\r
102 <dl><dt><strong>__dict__</strong></dt>
\r
103 <dd><tt>dictionary for instance variables (if defined)</tt></dd>
\r
105 <dl><dt><strong>__weakref__</strong></dt>
\r
106 <dd><tt>list of weak references to the object (if defined)</tt></dd>
\r
108 </td></tr></table> <p>
\r
109 <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
\r
110 <tr bgcolor="#ffc8d8">
\r
111 <td colspan=3 valign=bottom> <br>
\r
112 <font color="#000000" face="helvetica, arial"><a name="TableCell">class <strong>TableCell</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
\r
114 <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
\r
115 <td colspan=2><tt>a <a href="#TableCell">TableCell</a> <a href="__builtin__.html#object">object</a> is used to create a cell in a HTML table. (TD or TH)<br>
\r
118 - text: text in the cell (may contain HTML tags). May be any <a href="__builtin__.html#object">object</a> which<br>
\r
119 can be converted to a string using str().<br>
\r
120 - header: bool, false for a normal data cell (TD), true for a header cell (TH)<br>
\r
121 - bgcolor: str, background color<br>
\r
122 - width: str, width<br>
\r
123 - align: str, horizontal alignement (left, center, right, justify or char)<br>
\r
124 - char: str, alignment character, decimal point if not specified<br>
\r
125 - charoff: str, see HTML specs<br>
\r
126 - valign: str, vertical alignment (top|middle|bottom|baseline)<br>
\r
127 - style: str, CSS style<br>
\r
128 - attribs: dict, additional attributes for the TD/TH tag<br>
\r
130 Reference: <a href="http://www.w3.org/TR/html4/struct/tables.html#h-11.2.6">http://www.w3.org/TR/html4/struct/tables.html#h-11.2.6</a><br> </tt></td></tr>
\r
131 <tr><td> </td>
\r
132 <td width="100%">Methods defined here:<br>
\r
133 <dl><dt><a name="TableCell-__init__"><strong>__init__</strong></a>(self, text<font color="#909090">=''</font>, bgcolor<font color="#909090">=None</font>, header<font color="#909090">=False</font>, width<font color="#909090">=None</font>, align<font color="#909090">=None</font>, char<font color="#909090">=None</font>, charoff<font color="#909090">=None</font>, valign<font color="#909090">=None</font>, style<font color="#909090">=None</font>, attribs<font color="#909090">=None</font>)</dt><dd><tt><a href="#TableCell">TableCell</a> constructor</tt></dd></dl>
\r
135 <dl><dt><a name="TableCell-__str__"><strong>__str__</strong></a>(self)</dt><dd><tt>return the HTML code for the table cell as a string</tt></dd></dl>
\r
138 Data descriptors defined here:<br>
\r
139 <dl><dt><strong>__dict__</strong></dt>
\r
140 <dd><tt>dictionary for instance variables (if defined)</tt></dd>
\r
142 <dl><dt><strong>__weakref__</strong></dt>
\r
143 <dd><tt>list of weak references to the object (if defined)</tt></dd>
\r
145 </td></tr></table> <p>
\r
146 <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
\r
147 <tr bgcolor="#ffc8d8">
\r
148 <td colspan=3 valign=bottom> <br>
\r
149 <font color="#000000" face="helvetica, arial"><a name="TableRow">class <strong>TableRow</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
\r
151 <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
\r
152 <td colspan=2><tt>a <a href="#TableRow">TableRow</a> <a href="__builtin__.html#object">object</a> is used to create a row in a HTML table. (TR tag)<br>
\r
155 - cells: list, tuple or any iterable, containing one string or <a href="#TableCell">TableCell</a><br>
\r
156 <a href="__builtin__.html#object">object</a> for each cell<br>
\r
157 - header: bool, true for a header row (TH), false for a normal data row (TD)<br>
\r
158 - bgcolor: str, background color<br>
\r
159 - col_align, col_valign, col_char, col_charoff, col_styles: see <a href="#Table">Table</a> class<br>
\r
160 - attribs: dict, additional attributes for the TR tag<br>
\r
162 Reference: <a href="http://www.w3.org/TR/html4/struct/tables.html#h-11.2.5">http://www.w3.org/TR/html4/struct/tables.html#h-11.2.5</a><br> </tt></td></tr>
\r
163 <tr><td> </td>
\r
164 <td width="100%">Methods defined here:<br>
\r
165 <dl><dt><a name="TableRow-__init__"><strong>__init__</strong></a>(self, cells<font color="#909090">=None</font>, bgcolor<font color="#909090">=None</font>, header<font color="#909090">=False</font>, attribs<font color="#909090">=None</font>, col_align<font color="#909090">=None</font>, col_valign<font color="#909090">=None</font>, col_char<font color="#909090">=None</font>, col_charoff<font color="#909090">=None</font>, col_styles<font color="#909090">=None</font>)</dt><dd><tt><a href="#TableCell">TableCell</a> constructor</tt></dd></dl>
\r
167 <dl><dt><a name="TableRow-__str__"><strong>__str__</strong></a>(self)</dt><dd><tt>return the HTML code for the table row as a string</tt></dd></dl>
\r
170 Data descriptors defined here:<br>
\r
171 <dl><dt><strong>__dict__</strong></dt>
\r
172 <dd><tt>dictionary for instance variables (if defined)</tt></dd>
\r
174 <dl><dt><strong>__weakref__</strong></dt>
\r
175 <dd><tt>list of weak references to the object (if defined)</tt></dd>
\r
177 </td></tr></table></td></tr></table><p>
\r
178 <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
\r
179 <tr bgcolor="#eeaa77">
\r
180 <td colspan=3 valign=bottom> <br>
\r
181 <font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
\r
183 <tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
\r
184 <td width="100%"><dl><dt><a name="-Link"><strong>Link</strong></a>(text, url)</dt><dd><tt># much simpler definition of a link as a function:</tt></dd></dl>
\r
185 <dl><dt><a name="-link"><strong>link</strong></a>(text, url)</dt></dl>
\r
186 <dl><dt><a name="-list"><strong>list</strong></a>(*args, **kwargs)</dt><dd><tt>return HTML code for a list as a string. See <a href="#List">List</a> class for parameters.</tt></dd></dl>
\r
187 <dl><dt><a name="-table"><strong>table</strong></a>(*args, **kwargs)</dt><dd><tt>return HTML code for a table as a string. See <a href="#Table">Table</a> class for parameters.</tt></dd></dl>
\r
188 </td></tr></table><p>
\r
189 <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
\r
190 <tr bgcolor="#55aa55">
\r
191 <td colspan=3 valign=bottom> <br>
\r
192 <font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
\r
194 <tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
\r
195 <td width="100%"><strong>TABLE_STYLE_THINBORDER</strong> = 'border: 1px solid #000000; border-collapse: collapse;'<br>
\r
196 <strong>__author__</strong> = 'Philippe Lagadec'<br>
\r
197 <strong>__date__</strong> = '2009-07-28'<br>
\r
198 <strong>__version__</strong> = '0.04'</td></tr></table><p>
\r
199 <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
\r
200 <tr bgcolor="#7799ee">
\r
201 <td colspan=3 valign=bottom> <br>
\r
202 <font color="#ffffff" face="helvetica, arial"><big><strong>Author</strong></big></font></td></tr>
\r
204 <tr><td bgcolor="#7799ee"><tt> </tt></td><td> </td>
\r
205 <td width="100%">Philippe Lagadec</td></tr></table>
\r