Splitting layout.py
authorrgbecker
Fri, 14 Apr 2000 12:17:05 +0000
changeset 129 623baa767856
parent 128 a0676f013314
child 130 e95a230cb9ea
Splitting layout.py
reportlab/demos/gadflypaper/gfe.py
reportlab/demos/odyssey/fodyssey.py
reportlab/demos/pythonpoint/pythonpoint.py
reportlab/demos/pythonpoint/stdparser.py
reportlab/platypus/paraparser.py
reportlab/platypus/tables.py
--- a/reportlab/demos/gadflypaper/gfe.py	Fri Apr 14 11:54:57 2000 +0000
+++ b/reportlab/demos/gadflypaper/gfe.py	Fri Apr 14 12:17:05 2000 +0000
@@ -31,9 +31,12 @@
 #
 ###############################################################################
 #	$Log: gfe.py,v $
+#	Revision 1.7  2000/04/14 12:17:05  rgbecker
+#	Splitting layout.py
+#
 #	Revision 1.6  2000/03/08 13:06:39  andy_robinson
 #	Moved inch and cm definitions to reportlab.lib.units and amended all demos
-#
+#	
 #	Revision 1.5  2000/03/02 12:21:20  rgbecker
 #	Added recognition comment
 #	
@@ -49,14 +52,16 @@
 #	Revision 1.1.1.1  2000/02/15 15:15:57  rgbecker
 #	Initial setup of demos directory and contents.
 #	
-__version__=''' $Id: gfe.py,v 1.6 2000/03/08 13:06:39 andy_robinson Exp $ '''
+__version__=''' $Id: gfe.py,v 1.7 2000/04/14 12:17:05 rgbecker Exp $ '''
 __doc__=''
 
 #REPORTLAB_TEST_SCRIPT
 import sys
 from reportlab.platypus import layout
+from reportlab.platypus.paragraph import Paragraph
+from reportlab.lib.styles import getSampleStyleSheet
 
-styles = layout.getSampleStyleSheet()
+styles = getSampleStyleSheet()
 
 Title = "Integrating Diverse Data Sources with Gadfly 2"
 
@@ -111,7 +116,7 @@
 
 HeaderStyle = styles["Heading1"] # XXXX
 
-def header(txt, style=HeaderStyle, klass=layout.Paragraph, sep=0.3):
+def header(txt, style=HeaderStyle, klass=Paragraph, sep=0.3):
     s = layout.Spacer(0.2*inch, sep*inch)
     Elements.append(s)
     para = klass(txt, style)
--- a/reportlab/demos/odyssey/fodyssey.py	Fri Apr 14 11:54:57 2000 +0000
+++ b/reportlab/demos/odyssey/fodyssey.py	Fri Apr 14 12:17:05 2000 +0000
@@ -31,24 +31,30 @@
 #
 ###############################################################################
 #	$Log: fodyssey.py,v $
+#	Revision 1.4  2000/04/14 12:17:05  rgbecker
+#	Splitting layout.py
+#
 #	Revision 1.3  2000/04/13 14:48:41  rgbecker
 #	<para> tag added in layout.py paraparser.py
-#
+#	
 #	Revision 1.2  2000/04/12 16:24:34  rgbecker
 #	XML Tagged Paragraph parser changes
 #	
 #	Revision 1.1  2000/04/06 08:58:09  rgbecker
 #	Paragraph formatting version of odyssey.py
 #	
-__version__=''' $Id: fodyssey.py,v 1.3 2000/04/13 14:48:41 rgbecker Exp $ '''
+__version__=''' $Id: fodyssey.py,v 1.4 2000/04/14 12:17:05 rgbecker Exp $ '''
 __doc__=''
 
 #REPORTLAB_TEST_SCRIPT
 import sys, copy, string, os
 from reportlab.platypus import layout
+from reportlab.platypus.paragraph import Paragraph
 from reportlab.lib.units import inch
+from reportlab.lib.styles import getSampleStyleSheet
+from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
 
-styles = layout.getSampleStyleSheet()
+styles = getSampleStyleSheet()
 
 Title = "Odyssey"
 
@@ -76,7 +82,7 @@
 Elements = []
 
 ChapterStyle = copy.copy(styles["Heading1"])
-ChapterStyle.alignment = layout.TA_CENTER
+ChapterStyle.alignment = TA_CENTER
 ChapterStyle.fontsize = 14
 
 def newPage():
@@ -84,28 +90,28 @@
 
 def chapter(txt, style=ChapterStyle):
 	newPage()
-	Elements.append(layout.Paragraph(txt, style))
+	Elements.append(Paragraph(txt, style))
 	Elements.append(layout.Spacer(0.2*inch, 0.3*inch))
 
 ParaStyle = copy.deepcopy(styles["Normal"])
 if 'right' in sys.argv:
-	ParaStyle.alignment = layout.TA_RIGHT
+	ParaStyle.alignment = TA_RIGHT
 elif 'left' in sys.argv:
-	ParaStyle.alignment = layout.TA_LEFT
+	ParaStyle.alignment = TA_LEFT
 elif 'justify' in sys.argv:
-	ParaStyle.alignment = layout.TA_JUSTIFY
+	ParaStyle.alignment = TA_JUSTIFY
 elif 'center' in sys.argv or 'centre' in sys.argv:
-	ParaStyle.alignment = layout.TA_CENTER
+	ParaStyle.alignment = TA_CENTER
 else:
-	ParaStyle.alignment = layout.TA_JUSTIFY
+	ParaStyle.alignment = TA_JUSTIFY
 
 def p(txt, style=ParaStyle):
 	Elements.append(layout.Spacer(0.2*inch, 0.1*inch))
-	Elements.append(layout.Paragraph(txt, style))
+	Elements.append(Paragraph(txt, style))
 
 PreStyle = styles["Code"] 
 InitialStyle = copy.copy(PreStyle)
-InitialStyle.alignment = layout.TA_CENTER
+InitialStyle.alignment = TA_CENTER
 InitialStyle.fontsize = 14
 
 def pre(txt, style=PreStyle):
--- a/reportlab/demos/pythonpoint/pythonpoint.py	Fri Apr 14 11:54:57 2000 +0000
+++ b/reportlab/demos/pythonpoint/pythonpoint.py	Fri Apr 14 12:17:05 2000 +0000
@@ -31,9 +31,12 @@
 #
 ###############################################################################
 #	$Log: pythonpoint.py,v $
+#	Revision 1.13  2000/04/14 12:17:05  rgbecker
+#	Splitting layout.py
+#
 #	Revision 1.12  2000/04/14 08:56:20  rgbecker
 #	Drawable ==> Flowable
-#
+#	
 #	Revision 1.11  2000/04/10 09:05:49  andy_robinson
 #	- Fixed multi-line strings
 #	- added cached image so demo works without PIL
@@ -72,7 +75,7 @@
 #	Revision 1.1.1.1  2000/02/15 15:08:55  rgbecker
 #	Initial setup of demos directory and contents.
 #	
-__version__=''' $Id: pythonpoint.py,v 1.12 2000/04/14 08:56:20 rgbecker Exp $ '''
+__version__=''' $Id: pythonpoint.py,v 1.13 2000/04/14 12:17:05 rgbecker Exp $ '''
 # xml parser stuff for PythonPoint
 # PythonPoint Markup Language!
 __doc__="""
@@ -121,6 +124,9 @@
 
 from reportlab.pdfgen import canvas
 from reportlab.platypus import layout
+from reportlab.platypus.paragraph import Paragraph
+from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
+from reportlab.lib import styles
 import stdparser 
 
 
@@ -255,7 +261,7 @@
         self.style = None
 
     def getFlowable(self):
-        return layout.Paragraph(
+        return Paragraph(
                     self.rawtext,
                     getStyles()[self.style],
                     self.bulletText
@@ -440,7 +446,7 @@
         self.text = ''
         self.x = x
         self.y = y
-        self.align = layout.TA_LEFT
+        self.align = TA_LEFT
         self.font = 'Times-Roman'
         self.size = 12
         self.color = (0,0,0)
@@ -468,11 +474,11 @@
         canv.setFillColorRGB(r,g,b)
         cur_y = self.y
         for line in lines:
-            if self.align == layout.TA_LEFT:
+            if self.align == TA_LEFT:
                 canv.drawString(self.x, cur_y, line)
-            elif self.align == layout.TA_CENTER:
+            elif self.align == TA_CENTER:
                 canv.drawCentredString(self.x, cur_y, line)
-            elif self.align == layout.TA_RIGHT:
+            elif self.align == TA_RIGHT:
                 canv.drawRightString(self.x, cur_y, line)
             cur_y = cur_y - 1.2*self.size
                 
@@ -483,7 +489,7 @@
     """Returns a dictionary of styles to get you started.  We will
     provide a way to specify a module of these."""
     stylesheet = {}
-    ParagraphStyle = layout.ParagraphStyle
+    ParagraphStyle = styles.ParagraphStyle
     
     para = ParagraphStyle('Normal', None)   #the ancestor of all
     para.fontName = 'Times-Roman'
@@ -503,12 +509,12 @@
     stylesheet['Indent'] = para
 
     para = ParagraphStyle('Centered', stylesheet['Normal'])
-    para.alignment = layout.TA_CENTER
+    para.alignment = TA_CENTER
     stylesheet['Centered'] = para
     
     para = ParagraphStyle('BigCentered', stylesheet['Normal'])
     para.spaceBefore = 12
-    para.alignment = layout.TA_CENTER
+    para.alignment = TA_CENTER
     stylesheet['BigCentered'] = para
 
     para = ParagraphStyle('Italic', stylesheet['BodyText'])
@@ -519,14 +525,14 @@
     para.fontName = 'Times-Roman'
     para.fontSize = 48
     para.Leading = 58
-    para.alignment = layout.TA_CENTER
+    para.alignment = TA_CENTER
     stylesheet['Title'] = para
     
     para = ParagraphStyle('Heading1', stylesheet['Normal'])
     para.fontName = 'Times-Bold'
     para.fontSize = 36
     para.leading = 44
-    para.alignment = layout.TA_CENTER
+    para.alignment = TA_CENTER
     stylesheet['Heading1'] = para
     
     para = ParagraphStyle('Heading2', stylesheet['Normal'])
--- a/reportlab/demos/pythonpoint/stdparser.py	Fri Apr 14 11:54:57 2000 +0000
+++ b/reportlab/demos/pythonpoint/stdparser.py	Fri Apr 14 12:17:05 2000 +0000
@@ -31,9 +31,12 @@
 #
 ###############################################################################
 #	$Log: stdparser.py,v $
+#	Revision 1.3  2000/04/14 12:17:05  rgbecker
+#	Splitting layout.py
+#
 #	Revision 1.2  2000/04/06 12:15:38  andy_robinson
 #	Updated example XML to include full tag reference
-#
+#	
 #	Revision 1.1  2000/04/06 09:47:20  andy_robinson
 #	Added several new shape tags.
 #	Broke out parser into separate module, to
@@ -56,6 +59,7 @@
 import imp
 import pythonpoint
 from reportlab.platypus import layout
+from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
 
 class PPMLParser(xmllib.XMLParser):
     attributes = {
@@ -416,11 +420,13 @@
         self._curString.font = args['font']
         self._curString.size = eval(args['size'])
         if args['align'] == 'left':
-            self._curString.align = layout.TA_LEFT
+            self._curString.align = TA_LEFT
         elif args['align'] == 'center':
-            self._curString.align = layout.TA_CENTER
+            self._curString.align = TA_CENTER
         elif args['align'] == 'right':
-            self._curString.align = layout.TA_RIGHT
+            self._curString.align = TA_RIGHT
+        elif args['align'] == 'justify':
+            self._curString.align = TA_JUSTIFY
         #text comes later within the tag
         
     def end_string(self):
--- a/reportlab/platypus/paraparser.py	Fri Apr 14 11:54:57 2000 +0000
+++ b/reportlab/platypus/paraparser.py	Fri Apr 14 12:17:05 2000 +0000
@@ -369,7 +369,7 @@
 			return style, None
 
 if __name__=='__main__':
-	from reportlab.platypus.layout import cleanBlockQuotedText
+	from reportlab.platypus.paragraph import cleanBlockQuotedText
 	_parser=ParaParser()
 
 	style=ParaFrag()
--- a/reportlab/platypus/tables.py	Fri Apr 14 11:54:57 2000 +0000
+++ b/reportlab/platypus/tables.py	Fri Apr 14 12:17:05 2000 +0000
@@ -31,9 +31,12 @@
 #
 ###############################################################################
 #	$Log: tables.py,v $
+#	Revision 1.7  2000/04/14 12:17:05  rgbecker
+#	Splitting layout.py
+#
 #	Revision 1.6  2000/04/14 11:54:57  rgbecker
 #	Splitting layout.py
-#
+#	
 #	Revision 1.5  2000/04/14 08:56:20  rgbecker
 #	Drawable ==> Flowable
 #	
@@ -46,14 +49,15 @@
 #	Revision 1.2  2000/02/15 15:47:09  rgbecker
 #	Added license, __version__ and Logi comment
 #	
-__version__=''' $Id: tables.py,v 1.6 2000/04/14 11:54:57 rgbecker Exp $ '''
+__version__=''' $Id: tables.py,v 1.7 2000/04/14 12:17:05 rgbecker Exp $ '''
 __doc__="""
 Tables are created by passing the constructor a tuple of column widths, a tuple of row heights and the data in
 row order. Drawing of the table can be controlled by using a TableStyle instance. This allows control of the
 color and weight of the lines (if any), and the font, alignment and padding of the text.
 """
 from reportlab.platypus import layout
-from reportlab.lib.styles import PropertySet
+from reportlab.platypus.paragraph import Paragraph
+from reportlab.lib.styles import PropertySet, getSampleStyleSheet
 import operator
 
 _stringtype = type('')
@@ -329,11 +333,11 @@
         ('Hats', 893, 912, '1,212', 643, 789, 159, 888, '1,298', 832, 453, '1,344','2,843')
         )
     doc = layout.SimpleFlowDocument('testtables.pdf', layout.DEFAULT_PAGE_SIZE, 1)
-    styleSheet = layout.getSampleStyleSheet()
+    styleSheet = getSampleStyleSheet()
     lst = []
-    lst.append(layout.Paragraph("Tables", styleSheet['Heading1']))
-    lst.append(layout.Paragraph(__doc__, styleSheet['BodyText']))
-    lst.append(layout.Paragraph("The Tables (shown in different styles below) were created using the following code:", styleSheet['BodyText']))
+    lst.append(Paragraph("Tables", styleSheet['Heading1']))
+    lst.append(Paragraph(__doc__, styleSheet['BodyText']))
+    lst.append(Paragraph("The Tables (shown in different styles below) were created using the following code:", styleSheet['BodyText']))
     lst.append(layout.Preformatted("""
     colwidths = (50, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32)
     rowheights = (24, 16, 16, 16, 16)
@@ -348,7 +352,7 @@
         )   
     t = Table(colwidths, rowheights,  data)
     """, styleSheet['Code'], dedent=4))
-    lst.append(layout.Paragraph("""
+    lst.append(Paragraph("""
     You can then give the Table a TableStyle object to control its format. The first TableStyle used was
     created as follows:
     """, styleSheet['BodyText']))
@@ -358,53 +362,53 @@
      ('ALIGN', (1,1), (-1,-1), 'RIGHT')]
     )
     """, styleSheet['Code']))
-    lst.append(layout.Paragraph("""
+    lst.append(Paragraph("""
     TableStyles are created by passing in a list of commands. There are two types of commands - line commands
     and cell formatting commands. In all cases, the first three elements of a command are the command name,
     the starting cell and the ending cell.
     """, styleSheet['BodyText']))
-    lst.append(layout.Paragraph("""
+    lst.append(Paragraph("""
     Line commands always follow this with the weight and color of the desired lines. Colors can be names,
     or they can be specified as a (R,G,B) tuple, where R, G and B are floats and (0,0,0) is black. The line
     command names are: GRID, BOX, OUTLINE, INNERGRID, LINEBELOW, LINEABOVE, LINEBEFORE
     and LINEAFTER. BOX and OUTLINE are equivalent, and GRID is the equivalent of applying both BOX and
     INNERGRID.
     """, styleSheet['BodyText']))
-    lst.append(layout.Paragraph("""
+    lst.append(Paragraph("""
     Cell formatting commands are:
     """, styleSheet['BodyText']))
-    lst.append(layout.Paragraph("""
+    lst.append(Paragraph("""
     FONT - takes fontname, fontsize and (optional) leading.
     """, styleSheet['Definition']))
-    lst.append(layout.Paragraph("""
+    lst.append(Paragraph("""
     TEXTCOLOR - takes a color name or (R,G,B) tuple.
     """, styleSheet['Definition']))
-    lst.append(layout.Paragraph("""
+    lst.append(Paragraph("""
     ALIGNMENT (or ALIGN) - takes one of LEFT, RIGHT and CENTRE (or CENTER).
     """, styleSheet['Definition']))
-    lst.append(layout.Paragraph("""
+    lst.append(Paragraph("""
     LEFTPADDING - defaults to 6.
     """, styleSheet['Definition']))
-    lst.append(layout.Paragraph("""
+    lst.append(Paragraph("""
     RIGHTPADDING - defaults to 6.
     """, styleSheet['Definition']))
-    lst.append(layout.Paragraph("""
+    lst.append(Paragraph("""
     BOTTOMPADDING - defaults to 3.
     """, styleSheet['Definition']))
-    lst.append(layout.Paragraph("""
+    lst.append(Paragraph("""
     A tablestyle is applied to a table by calling Table.setStyle(tablestyle).
     """, styleSheet['BodyText']))
     t = Table(colwidths, rowheights,  data)
     t.setStyle(GRID_STYLE)
     lst.append(layout.PageBreak())
-    lst.append(layout.Paragraph("This is GRID_STYLE\n", styleSheet['BodyText']))
+    lst.append(Paragraph("This is GRID_STYLE\n", styleSheet['BodyText']))
     lst.append(t)
     
     t = Table(colwidths, rowheights,  data)
     t.setStyle(BOX_STYLE)
-    lst.append(layout.Paragraph("This is BOX_STYLE\n", styleSheet['BodyText']))
+    lst.append(Paragraph("This is BOX_STYLE\n", styleSheet['BodyText']))
     lst.append(t)
-    lst.append(layout.Paragraph("""
+    lst.append(Paragraph("""
     It was created as follows:
     """, styleSheet['BodyText']))
     lst.append(layout.Preformatted("""
@@ -416,9 +420,9 @@
     
     t = Table(colwidths, rowheights,  data)
     t.setStyle(LABELED_GRID_STYLE)
-    lst.append(layout.Paragraph("This is LABELED_GRID_STYLE\n", styleSheet['BodyText']))
+    lst.append(Paragraph("This is LABELED_GRID_STYLE\n", styleSheet['BodyText']))
     lst.append(t)
-    lst.append(layout.Paragraph("""
+    lst.append(Paragraph("""
     It was created as follows:
     """, styleSheet['BodyText']))
     lst.append(layout.Preformatted("""
@@ -434,9 +438,9 @@
     
     t = Table(colwidths, rowheights,  data)
     t.setStyle(COLORED_GRID_STYLE)
-    lst.append(layout.Paragraph("This is COLORED_GRID_STYLE\n", styleSheet['BodyText']))
+    lst.append(Paragraph("This is COLORED_GRID_STYLE\n", styleSheet['BodyText']))
     lst.append(t)
-    lst.append(layout.Paragraph("""
+    lst.append(Paragraph("""
     It was created as follows:
     """, styleSheet['BodyText']))
     lst.append(layout.Preformatted("""
@@ -451,9 +455,9 @@
     
     t = Table(colwidths, rowheights,  data)
     t.setStyle(LIST_STYLE)
-    lst.append(layout.Paragraph("This is LIST_STYLE\n", styleSheet['BodyText']))
+    lst.append(Paragraph("This is LIST_STYLE\n", styleSheet['BodyText']))
     lst.append(t)
-    lst.append(layout.Paragraph("""
+    lst.append(Paragraph("""
     It was created as follows:
     """, styleSheet['BodyText']))
     lst.append(layout.Preformatted("""
@@ -475,9 +479,9 @@
      ('BACKGROUND', (0,0), (-1,0), (0,0.7,0.7))]
     )
     t.setStyle(ts)
-    lst.append(layout.Paragraph("This is a custom style\n", styleSheet['BodyText']))
+    lst.append(Paragraph("This is a custom style\n", styleSheet['BodyText']))
     lst.append(t)
-    lst.append(layout.Paragraph("""
+    lst.append(Paragraph("""
     It was created as follows:
     """, styleSheet['BodyText']))
     lst.append(layout.Preformatted("""