<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
Pierre Quentel wrote:
<blockquote
cite="mid:%3C0f6bd3c1-6c54-434b-9370-7dc49653d9ed@35g2000yqa.googlegroups.com%3E"
type="cite">
<pre wrap="">On 12 jan, 04:26, Alan Harris-Reid <a class="moz-txt-link-rfc2396E" href="mailto:aharrisr...@googlemail.com"><aharrisr...@googlemail.com></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi,
Does anyone know where I can find any decent dynamically-constructed
HTML control classes (dropdown list, table, input field, checkbox, etc.)
written in Python. For example, for a HTML table I would like something
like...
MyTable =tml_table() # instantiate class
MyTable.data =ata_list # data-list (eg. cursor from SQL SELECT
statement)
MyTable.border =
MyTable.width =87
MyTable.column_headers =ol_headers # list or tuple of column-headers
table_code =yTable.table.create() # returns string
containing appropriate HTML code
I don't mind writing my own classes (it will be good practice for me),
but I don't want to re-invent the wheel if it can be avoided.
TIA,
Alan Harris-Reid
</pre>
</blockquote>
<pre wrap=""><!---->
Hi,
There are a few modules to generate HTML from Python : there is a list
at <a class="moz-txt-link-freetext" href="http://wiki.python.org/moin/Templating">http://wiki.python.org/moin/Templating</a>, section HTML Generation
packages
With HTMLTags, your example would be coded like this :
from HTMLTags import *
table =ABLE(border=1,width˜7)
table <=R(Sum([TD(header) for header in col_headers]))
for result in data_list:
table <=R(Sum([TD(value) for value in result]))
print table
The operator <=eans "add child" in the DOM tree structure, it avoids
having to nest tags with brackets
- Pierre</pre>
</blockquote>
<br>
Thanks Pierre. I can see this module being very useful. I have
downloaded the code from the Activestate site (is that the latest
version?) and will try it out as soon as possible.<br>
Is HTMLTags Python3 compatible? (I am using 3.1).<br>
<br>
Regards,<br>
Alan Harris-Reid<br>
<br>
</body>
</html>