[reportlab-users] UnboundLocalError inside platypus api

Mike Hostetler mike at squarepegsystems.com
Thu Nov 29 14:52:18 EST 2018


I'd even argue that it's not even consistant...with Tables you style it
like so:

    t.setStyle(TableStyle([('VALIGN',(0,0),(-1,0),'TOP'),
                           ('LINEABOVE',(0,0),(-1,0),1.5,colors.black),
                           ('LINEBELOW',(0,0),(-1,0),1.5,colors.black),
                           ('FONT',(0,0),(0,-1),'Times-Bold',12),
                           ('FONT',(1,1),(-1,-1),'Times-Roman',8),
                           ('ALIGN',(0,0),(-1,-1),'CENTER'),
                           ]))

Anyway thanks Tim -- using the enums worked. And I agree about the more
useful error message.

On Thu, Nov 29, 2018 at 12:03 PM Tim Roberts <timr at probo.com> wrote:

> Mike Hostetler wrote:
> >
> > It happens when it's trying to apply this custom style. If I use
> > style['Normal'], it works fine:
> >
> > class TitleStyle(ParagraphStyle):
> >     def __init__(self):
> >         self.__dict__.update(self.defaults)
> >
> > self.name <http://self.name>="Title"
> >         self.fontName='Times-Bold'
> >         self.alignment='LEFT'
>
> "alignment" is not a string value, it's an enumeration.  You need to use:
>
>      from reportlab.lib.enums import *
> ...
>      self.alignment = TA_LEFT
>
> One might argue that the library should have presented a more meaningful
> error message in this case, by supplying a default value for dpl and
> checking that the default managed to sneak through.
>
> --
> Tim Roberts, timr at probo.com
> Providenza & Boekelheide, Inc.
>
> _______________________________________________
> reportlab-users mailing list
> reportlab-users at lists2.reportlab.com
> https://pairlist2.pair.net/mailman/listinfo/reportlab-users
>


-- 
Mike Hostetler
SquarePeg Systems
http://www.squarepegsystems.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20181129/7663a97b/attachment.html>


More information about the reportlab-users mailing list