[reportlab-users] Frames Question

Robin Becker reportlab-users@reportlab.com
Wed, 16 Oct 2002 00:07:43 +0100


In article <001201c2749a$81c5ba80$5b01a8c0@Dalbar.com>, Marc Stober <MStober@dalbar.com> writes
>
>Hi:
>
>I was wondering if there is a way to have two frames in a PageTemplate
>(i.e., two columns) that would be populated with 2 different lists of
>flowables? For example, when the left frame is full, the story should
>continue in the left frame of page 2 -- not the right frame.
>
>Thank you,
>Marc Stober
>mstober@dalbar.com
yes, but you need to have a special doc template. The original platypus test used a dual story. It's in CVS 
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/reportlab/reportlab/platypus/test/Attic/testplatypus.py?rev=1.24&content-type=text/vnd.viewcvs-markup

The class is called AndyTemplate, but I think it was my work originally.

class AndyTemplate(BaseDocTemplate):
        _invalidInitArgs = ('pageTemplates',)
        def __init__(self, filename, **kw):
                frame1 = platypus.Frame(inch, 5.6*inch, 6*inch, 5.2*inch,id='F1')
                frame2 = platypus.Frame(inch, inch, 6*inch, 4.5*inch, showBoundary=1,id='F2')
                self.allowSplitting = 0
                apply(BaseDocTemplate.__init__,(self,filename),kw)
                self.addPageTemplates(PageTemplate('normal',[frame1,frame2],framePage))

        def fillFrame(self,flowables):
                f = self.frame
                while len(flowables)>0 and f is self.frame:
                        self.handle_flowable(flowables)

        def build(self, flowables1, flowables2):
                assert filter(lambda x: not isinstance(x,Flowable), flowables1)==[], "flowables1 argument error"
                assert filter(lambda x: not isinstance(x,Flowable), flowables2)==[], "flowables2 argument error"
                self._startBuild()
                while (len(flowables1) > 0 or len(flowables1) > 0):
                        self.clean_hanging()
                        self.fillFrame(flowables1)
                        self.fillFrame(flowables2)

                self._endBuild()

 
-- 
Robin Becker