Dynamic HTML controls

Alan Harris-Reid alan at baselinedata.co.uk
Fri Jan 15 03:25:46 CET 2010

Pierre Quentel wrote:
> On 12 jan, 04:26, Alan Harris-Reid <aharrisr... at googlemail.com> wrote:
>> 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
> Hi,
> There are a few modules to generate HTML from Python : there is a list
> at http://wiki.python.org/moin/Templating, 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

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.
Is HTMLTags Python3 compatible? (I am using 3.1).

Alan Harris-Reid

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100115/7c4d89f7/attachment.html>

More information about the Python-list mailing list