[reportlab-users] Re: Tablestyle.add() tuple unpack problem

Derek Basch reportlab-users@reportlab.com
Wed, 25 Sep 2002 22:14:58 -0700 (PDT)


James,
I see what you mean about putting a list within a
list. I fixed it and it works great. I can add
tablestyle elements on the fly now. Makes for some
great reports. My problem was that I used the manual
as reference: 

TableStyle.add(commandSequence)

This method allows you to add commands to an existing
TableStyle, i.e. you can build up
TableStyles in multiple statements.

LIST_STYLE.add([('BACKGROUND', (0,0), (-1,0),
colors.Color(0,0.7,0.7))]) 

This is obviously wrong! If anyone with ReportLab is
reading this please fix this error :).
Thanks,
Derek Basch

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


Disclaimer:  I'm also slogging up the ReportLab
learning curve.

Disclaimer aside, I think the problem is in the syntax
of the 'add' 
method.  You have:

tblstyle.add([('BACKGROUND', (0,0), (-1,0),
colors.Color(0,0.7,0.7))])

When you use TableStyle you're creating a list of
tuples.  When you 
execute the above statement, you're putting a list
within a list.  
That's fine syntactically with Python but causing an
error with 
Reportlab. 

Try this:

tblstyle.add('BACKGROUND', (0,0), (-1,0),
colors.Color(0,0.7,0.7))

The ReportLab supplied example test_platypus_tables.py
has helped me 
out.

__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com