Re: UnboundLocalError inside platypus api

Mike Hostetler <[email protected]>
Newsgroups gmane.comp.python.reportlab.user
Message-ID <CAE1_9RU0Dk=KPD3NpVANTmpy23Z3CbVrPLVAp_Rv3FMiv=JtVg@mail.gmail.com>
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 <[email protected]> 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, [email protected]
> Providenza & Boekelheide, Inc.
>
> _______________________________________________
> reportlab-users mailing list
> [email protected]
> https://pairlist2.pair.net/mailman/listinfo/reportlab-users
>


-- 
Mike Hostetler
SquarePeg Systems
http://www.squarepegsystems.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.