[reportlab-users] Custom Flowables - Can't get shapes.Drawing() to paint to the story/canvas

Tim Roberts timr at probo.com
Thu Nov 29 15:12:45 EST 2012


J. R. Carroll wrote:

>

> I haven't forgotten about my other thread, but in preparation to

> (hopefully) finalize my findings and report back, I started making a

> "print test page" (which, once I am done, I'd be happy to share).

>

> I am having a problem following the reportlab manual/examples online

> for creating my own custom flowable. As I understand it, a

> shapes.Drawing() object is not a flowable by default (correct?). If I

> want it to be a flowable I have to create my own flowable object

> wrapped around it (or did I misunderstand)?

>

> I have created my own custom class to deal with the strip chart grids

> I am working with (as noted in my previous thread I started), but I

> cannot get the class to return a flowable that story.build() can work

> with (see the error at the bottom of this email).

>

> What I am trying to achieve is a "small sample grid" (which is drawn

> by my class), then immediately below that is the grid color name + RGB

> color reference. Eventually, I was going to build it so it would

> print 4-wide, and as many necessary "down". So it would be a matrix

> of finely printed, super small/fine, grid lines with different colors

> (which I can then use to determine which colors would work best on a

> variety of printers + work with our marketing department and MD's to

> select the colors that will work the best in the field (and be accepted).


This is not the right approach. The immediate problem is that you are
taking a flowable (your Grid_test) and trying to use it as the contents
of another flowable (Paragraph). That won't work.

Do you really need the flowable/story approach? That is, are you really
in a situation where you want to have ReportLab decide on the placement
and flow of the individual components? I would have guessed you
weren't. If you want things laid out in a grid with specific
placements, then forget about platypus entirely: forget about
DocTemplates and flowables and stories. Just create your own canvas,
and draw the stuff you need exactly where you need it. It's like the
difference between doing a drawing in Word and doing it in Visio.

I tend to be a bit of a control freak -- I like to know exactly where
things are going to be -- so I almost NEVER use the flowable part of
ReportLab. I always draw directly to a canvas.

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



More information about the reportlab-users mailing list