From: Morten W. P. <mo...@us...> - 2002-03-05 17:15:57
|
Update of /cvsroot/warp-framework/warp_framework In directory usw-pr-cvs1:/tmp/cvs-serv20359 Added Files: layout_utilities.py Log Message: Adding layout utilities --- NEW FILE --- ############################################################################## # Thingamy Public License (TPL) Version 0.9 # ----------------------------------------- # # Copyright (C) 2001 Thingamy Ltd. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # 1. Redistributions in source code must retain the above copyright # notice, this list of conditions, and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions, and the following disclaimer in # the documentation and/or other materials provided with the # distribution. # # 3. All advertising materials and documentation mentioning # features derived from or use of this software must display # the following acknowledgement: # # "This product includes software developed by Thingamy Ltd # (http://www.thingamy.com/)." # # In the event that the product being advertised includes an # intact Thingamy distribution (with copyright and license included) # then this clause is waived. # # 4. Modified redistributions of any form whatsoever must retain # the following acknowledgment: # # "This product includes software developed by Thingamy Ltd # (http://www.thingamy.com/)." # # Intact (re-)distributions of any official Thingamy release do not # require an external acknowledgement. # # 5. Modifications are encouraged but must be packaged separately as # patches to official Thingamy releases. Distributions that do not # clearly separate the patches from the original work must be clearly # labeled as unofficial distributions. Modifications which do not # carry the name Thingamy may be packaged in any form, as long as they # conform to all of the clauses above. # # # Disclaimer # # THIS SOFTWARE IS PROVIDED BY THINGAMY LTD. ``AS IS'' AND ANY # EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THINGAMY OR ITS # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # ############################################################################## # $Author: morphex $ # $Date: 2002/03/05 17:15:54 $ # $Revision: 1.1 $ html_sheet = """<div style="background-color: %(background_color)s; float: %(float)s; width: %(width)s; padding: %(padding)s; border-color: %(border_color)s; border-style: %(border_style)s; border-width: %(border_width)s; margin: %(margin)s;"> <h4 style="text-align: center;">%(caption)s</h4> <table border="0" width="100%%" style="width: 100%%;" > %(sheet_data)s </table> </div> """ html_sheet_data_entry = """ <tr> <th style="text-align: left; vertical-align: top; width: 25%%;">%(title)s</th> <td style="width: 90%%;" width="90%%">%(data)s</td> </tr>""" class sheet: """Simple class used for presenting something in a sheet.""" def __init__(self, caption='', background_color='#ebf4fa', float='left', width='48%', padding='3px', border_color='#cccccc', border_style='solid', border_width='1px', margin='0.3em'): """Initilalizes the instance.""" self.caption = caption self.entries = [] # Layout / CSS stuff self.background_color = background_color self.float = float self.width = width self.padding = padding self.border_color = border_color self.border_style = border_style self.border_width = border_width self.margin = margin def add_entry(self, title, value): self.entries.append((title, value)) def render(self): html_data = "" for entry in self.entries: html_data += html_sheet_data_entry % {'title':entry[0], 'data':entry[1]} return html_sheet % {'caption':self.caption, 'sheet_data':html_data, 'background_color':self.background_color, 'float':self.float, 'width':self.width, 'padding':self.padding, 'border_color':self.border_color, 'border_style':self.border_style, 'border_width':self.border_width, 'margin':self.margin} |