[reportlab-users] Layout Help

Rob McCulley RMcCulley at county24.com
Tue Feb 26 18:03:42 EST 2008


Thanks for the response time. I'm trying to go this route using
.drawOn, and everything works fine, except for tables.

My code looks like this:

RLmap = Image(mapimg,width=23*inch,height=34*inch)
RLmap.hAlign = "CENTER"
RLmap.drawOn(c1,0.5*inch,0.5*inch)
title1 = Paragraph(title,styleN)
title2 = Paragraph(compdist,styleN)
logo = RLImage(logo,width=2.5*inch,height=1.56*inch)
cols = [3*inch]
rows = [1.6*inch,0.75*inch,0.75*inch]
data = [[logo],[title1],[title2]]
tblock = Table(data,colWidths=cols,rowHeights=rows)

tblock.setStyle(TableStyle([('BOX',(0,0),(-1,-1),2,colors.black),

('GRID',(0,0),(-1,-1),2,colors.black),
('ALIGN',(0,0),(-1,-1),'CENTER'),

('VALIGN',(0,0),(-1,-1),'MIDDLE')]))
tblock.drawOn(c1,0.5*inch,0.5*inch)
c1.showPage()


And the error I get is this:

Traceback (most recent call last):
File "S:\Rob\Python_Scripts\makeRoadBanMaps.py", line 716, in <module>
processShapes(shplist,indir)
File "S:\Rob\Python_Scripts\makeRoadBanMaps.py", line 178, in
processShapes
tblock.drawOn(c1,0.5*inch,0.5*inch)
File "C:\Python25\Lib\site-packages\reportlab\platypus\flowables.py",
line 102
, in drawOn
self._drawOn(canvas)
File "C:\Python25\Lib\site-packages\reportlab\platypus\flowables.py",
line 86,
in _drawOn
self.draw()#this is the bit you overload
File "C:\Python25\Lib\site-packages\reportlab\platypus\tables.py",
line 1266,
in draw
self._drawBkgrnd()
File "C:\Python25\Lib\site-packages\reportlab\platypus\tables.py",
line 1289,
in _drawBkgrnd
colpositions = self._colpositions
AttributeError: Table instance has no attribute '_colpositions'
Can Tables be added using .drawOn? Or is there another way to draw the
table at a specified position?

Thanks,
Rob

-----Original Message-----
From: reportlab-users-bounces at reportlab.com
[mailto:reportlab-users-bounces at reportlab.com] On Behalf Of Tim Roberts
Sent: Tuesday, February 26, 2008 2:25 PM
To: Support list for users of Reportlab software
Subject: Re: [reportlab-users] Layout Help

Rob McCulley wrote:

>

> Hi all,

>

>

>

> I'm a bit of a reportlab newb. I've used it for awhile, but only for

> one specific task, and outside of that, I know very little.

>

>

>

> I need a little help in setting up my document layout. I've attached

> a .png file showing essentially what I'm trying to create. One large

> map document (the map will be a .png image), and then a legend and

> title block in the bottom left.

>

>

>

> The map image is the same size as the page, so the I need the lower

> left corner of the map to be covered by the legend and the title

> block. How do I do this? My initial thought was to use tables, but

> the map area of the document is non-rectangular. Here is what I have

> so far:

>

>

>

> if os.path.isfile(outfile):

>

> os.remove(outfile)

>

> c1 = Canvas(outfile)

>

> mapsize = (24*inch,36*inch)

>

> c1.setPageSize(mapsize)

>

> mapimage = Image(mappath,width=23*inch,height=34*inch)

>

> data = [[mapimage]]

>

> t1 = RLTable(data)

>

> t1.setStyle(TableStyle([('BOX',(0,0),(-1,-1),1,colors.black),

>

>

> ('ALIGN',(0,0),(-1,-1),'CENTER'),

>

>

> ('VALIGN',(0,0),(-1,-1),'MIDDLE')]))

>

> p1 = [t1]

>

> f1 =

Frame(0.25*inch,0.25*inch,23.5*inch,35.5*inch,showBoundary=1)

>

> f1.addFromList(p1,c1)

>

> c1.showPage()

>

>

>

> I've already created two other table elements, one for the legend and

> one for the title block, and then it dawned on me, that I don't have

> clue how to draw these two tables on top of the map table. Can I do

this?

>


Don't use tables at all. This is not an application where a flowable
helps you. Just place the three components directly at their
appropriate positions. Put the image down first, then lay the legend
and title block over the top of it.

--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.

_______________________________________________
reportlab-users mailing list
reportlab-users at reportlab.com
http://two.pairlist.net/mailman/listinfo/reportlab-users


More information about the reportlab-users mailing list