[reportlab-users] Printing Tuples From A List

Rich Shepard rshepard at appl-ecosys.com
Wed Oct 10 22:50:03 EDT 2007


On Wed, 10 Oct 2007, Rich Shepard wrote:


> Good. Back for more testing.


I have output. But, it's one string per line. I'd like each tuple on the
same line, separated by a tab (or arrow dingbat). Where in the doc is that
explained? I cannot use textobject.textLine(pair) because there's nore than
one string in the list.

Cleaned up code and pdf output attached.

Rich

--
Richard B. Shepard, Ph.D. | The Environmental Permitting
Applied Ecosystem Services, Inc. | Accelerators(TM)
<http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
-------------- next part --------------
#!/usr/bin/env python

from pysqlite2 import dbapi2 as sqlite3
from reportlab.pdfgen import canvas
from reportlab.lib import colors
from reportlab.lib.units import inch
from reportlab.lib.pagesizes import LETTER, landscape, portrait

con = sqlite3.connect('burro-breath.db', isolation_level=None)
cur = con.cursor()

cur.execute("SELECT comp1, comp2 from Pairs where pair_cat='Economic'")
EcoPairs = cur.fetchall()

cur.execute("SELECT comp1, comp2 from Pairs where pair_cat='Natural'")
NatPairs = cur.fetchall()

cur.execute("SELECT comp1, comp2 from Pairs where pair_cat='Societal'")
SocPairs = cur.fetchall()

cur.close()
con.close()

def outDo(c):
textobject = c.beginText()
textobject.setFont("Helvetica", 10)
textobject.setTextOrigin(0*inch, 9.0*inch)
for pair in EcoPairs:
textobject.textLines(pair)
c.drawText(textobject)

c = canvas.Canvas("EcoPairs.pdf")

outDo(c)
c.showPage()
c.save()

"""
EcoPairs:

[(u'Jobs', u'Tax base'), (u'Jobs', u'Infrastructure'), (u'Jobs',
u'Schools'), (u'Jobs', u'Housing'), (u'Jobs', u'Medical care'), (u'Jobs',
u'Sustainability'), (u'Jobs', u'Traffic volume'), (u'Tax base',
u'Infrastructure'), (u'Tax base', u'Schools'), (u'Tax base', u'Housing'),
(u'Tax base', u'Medical care'), (u'Tax base', u'Sustainability'), (u'Tax
base', u'Traffic volume'), (u'Infrastructure', u'Schools'),
(u'Infrastructure', u'Housing'), (u'Infrastructure', u'Medical care'),
(u'Infrastructure', u'Sustainability'), (u'Infrastructure', u'Traffic
volume'), (u'Schools', u'Housing'), (u'Schools', u'Medical care'),
(u'Schools', u'Sustainability'), (u'Schools', u'Traffic volume'),
(u'Housing', u'Medical care'), (u'Housing', u'Sustainability'), (u'Housing',
u'Traffic volume'), (u'Medical care', u'Sustainability'), (u'Medical care',
u'Traffic volume'), (u'Sustainability', u'Traffic volume')]
"""
-------------- next part --------------
A non-text attachment was scrubbed...
Name: EcoPairs.pdf
Type: application/pdf
Size: 2056 bytes
Desc:
Url : <http://two.pairlist.net/pipermail/reportlab-users/attachments/20071010/aeeb13d9/attachment-0001.pdf>


More information about the reportlab-users mailing list