[reportlab-users] Box with title and content portions having different background colors
Benjamin Higgins
bhiggins at gmail.com
Wed Jun 24 20:24:46 EDT 2009
I did something similar but like I stated earlier, this won't work when a
table cell doesn't fit on a page.
On Wed, Jun 24, 2009 at 12:47 PM, Michael Dorrian <michael.dorrian at gmail.com
> wrote:
> Have u tried nesting a table and paragraph inside another table....here is
> an example....u could also nest two paragraphs inside a table or add more as
> needed....the reportlab examples are good for this...test_table_layout.py
> has alot of info on this...
>
> from reportlab.platypus import Spacer, SimpleDocTemplate, Table, TableStyle
> from reportlab.lib.units import inch, cm
> from reportlab.platypus import Paragraph
> from reportlab.rl_config import defaultPageSize
> from reportlab.lib.units import inch,mm
> from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
> from reportlab.lib.pagesizes import A4,letter
> from reportlab.lib import colors
>
> def getTestTable():
> t = Table((('Header 1','header 2','Header 3'),
> ('Quarter 1',100,200),
> ('Quarter 2',100,200),
> ('Quarter 3',100,200),
> ('Quarter 4',100,200),
> ('Total',400,600)),
> (60,80,46),
> (24, 16,16,16,18,18)
> )
> return t
> def run():
> doc = SimpleDocTemplate(filename="NestedTableTest.pdf",
> pagesize=A4,
> topMargin=0.5*inch,
> bottomMargin=0.5*inch,
> leftMargin=0.5*inch,
>
> rightMargin=0.5*inch,showboundary=1)
>
> my_paragraph_style
> =ParagraphStyle(name='my_paragraph_style',fontName='Helvetica',fontSize=11,leading=12,spaceBefore=0,leftIndent=0)
> p1 = 'Table Title'
> Story = []
> ministy1 = TableStyle([('SPAN', (0, 0), (0, 0)),('GRID', (0,0),
> (-1,-1), 1.0, colors.black),])
> ts = TableStyle([
> ('GRID', (0,0), (-1,-1), 1.0, colors.black),
> ])
> t = getTestTable()
> t.setStyle(ts)
> P = Paragraph(p1,my_paragraph_style)
> NestedTable = Table([[P],[t]],(200),style=ministy1)
> Story.append(NestedTable)
> doc.build(Story)
> if __name__ == "__main__":
> run()
>
> On Wed, Jun 24, 2009 at 8:41 AM, Benjamin Higgins <bhiggins at gmail.com>wrote:
>
>> Well, there's going to be any number of these boxes appearing - it could
>> be just one or maybe a dozen, each with different contents and heights - so
>> I was hoping to implement it as a flowable element.
>>
>>
>> On Tue, Jun 23, 2009 at 3:45 PM, Roberto Alsina <
>> ralsina at netmanagers.com.ar> wrote:
>>
>>> On Tuesday 23 June 2009 19:24:29 Benjamin Higgins wrote:
>>> > Hi all,
>>> >
>>> > I've been trying to create a box that looks like this:
>>> >
>>> > +----------------+
>>> >
>>> > | Title |
>>> > |+--------------+|
>>> > |
>>> > || Content ||
>>> > |
>>> > |+--------------+|
>>> >
>>> > +----------------+
>>> >
>>> > I want the content area background to be white, and containing
>>> background
>>> > gray.
>>> >
>>> > My first attempt was to use a 3x3 table. This worked almost perfectly,
>>> but
>>> > when the content is bigger than a page I get a LayoutError Flowable
>>> "too
>>> > large" exception. From reading the archives, I gather that table cells
>>> > aren't able to be larger than a page.
>>> >
>>> > I'm now trying to find some other way to accomplish this design.
>>> >
>>> > Any tips?
>>>
>>> How about just drawing the grey background and white boxes in beforePage?
>>>
>>> --
>>> ("\''/").__..-''"`-. . Roberto Alsina
>>> `9_ 9 ) `-. ( ).`-._.`) KDE Developer (MFCH)
>>> (_Y_.)' ._ ) `._`. " -.-' http://lateral.netmanagers.com.ar
>>> _..`-'_..-_/ /-'_.' The 6,855th most popular site of Slovenia
>>> (l)-'' ((i).' ((!.' according to alexa.com (27/5/2007)
>>> "Our opponent is an alien starship packed with atomic bombs, I said.
>>> We have a protractor. Okay, I’ll go home and see if I can scrounge up a
>>> ruler and a piece of string." — Neal Stephenson
>>> _______________________________________________
>>> reportlab-users mailing list
>>> reportlab-users at reportlab.com
>>> http://two.pairlist.net/mailman/listinfo/reportlab-users
>>>
>>
>>
>> _______________________________________________
>> reportlab-users mailing list
>> reportlab-users at reportlab.com
>> http://two.pairlist.net/mailman/listinfo/reportlab-users
>>
>>
>
> _______________________________________________
> reportlab-users mailing list
> reportlab-users at reportlab.com
> http://two.pairlist.net/mailman/listinfo/reportlab-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20090624/cec9702b/attachment.htm>
More information about the reportlab-users
mailing list