[reportlab-users] Dynamic color for table rows
Steve Romanow
slestak989 at gmail.com
Tue Nov 1 08:54:23 EDT 2011
Can your colors be stored in a dict and use that data structure
instead of the literal color code?
On Tue, Nov 1, 2011 at 7:37 AM, Asif Jamadar <asif.jamadar at rezayat.net> wrote:
> The below code will generate the table for oils, which has following fields.
>
>
>
> fields = ('Test Name', 'Value', 'Unit', 'Method',
>
> 'Normal Limit', 'Caution Limit')
>
>
>
> all_oils = [(test.chemical_name, test.value, test.unit, test.method,
>
> test.CSUSNormal, test.CSUSCaution)
>
>
>
> for test in TestResult.objects.filterserial_no__id=doc.id)]
>
>
>
> oil_table = Table([fields] + all_oils
>
>
>
> oil_table.setStyle(TableStyle([('BACKGROUND', (0, 0), (-1, 0), '#a7a5a5'),
>
> ('FONTSIZE', (0, 0), (-1, 0), 6),
>
> ('GRID', (0, 0), (-1, -1), 2, '#a7a5a5'),
>
> ('FONTSIZE', (0, 0), (-1, -1), 8),
>
> ('FONTNAME',(1,1),(1,-1),'Times-Bold')]))
>
>
>
>
>
> Now how can I provide dynamic color for each row. Suppose my TestResult
> model is having field for color (I,e color=red)
>
>
>
> Each row will have different color as user selects
>
>
>
> How can I achieve this?
>
>
>
> _______________________________________________
> reportlab-users mailing list
> reportlab-users at lists2.reportlab.com
> http://two.pairlist.net/mailman/listinfo/reportlab-users
>
>
More information about the reportlab-users
mailing list