Example #1
0
 def make_my_style(self,
                   default_style,
                   name,
                   description,
                   size=9,
                   font=FONT_SERIF,
                   justified="left",
                   color=None,
                   align=PARA_ALIGN_CENTER,
                   shadow=None,
                   italic=0,
                   bold=0,
                   borders=0,
                   indent=None):
     """ Create paragraph and graphic styles of the same name """
     # Paragraph:
     f = FontStyle()
     f.set_size(size)
     f.set_type_face(font)
     f.set_italic(italic)
     f.set_bold(bold)
     p = ParagraphStyle()
     p.set_font(f)
     p.set_alignment(align)
     p.set_description(description)
     p.set_top_border(borders)
     p.set_left_border(borders)
     p.set_bottom_border(borders)
     p.set_right_border(borders)
     if indent:
         p.set(first_indent=indent)
     if justified == "left":
         p.set_alignment(PARA_ALIGN_LEFT)
     elif justified == "right":
         p.set_alignment(PARA_ALIGN_RIGHT)
     elif justified == "center":
         p.set_alignment(PARA_ALIGN_CENTER)
     default_style.add_paragraph_style(name, p)
     # Graphics:
     g = GraphicsStyle()
     g.set_paragraph_style(name)
     if shadow:
         g.set_shadow(*shadow)
     if color is not None:
         g.set_fill_color(color)
     if not borders:
         g.set_line_width(0)
     default_style.add_draw_style(name, g)