Open main menu

Gramps β

Changes

Report-writing tutorial

1,410 bytes removed, 08:58, 2 December 2025
m
Defining the ReportOptions class: The code moved to wiki template
In this example, no special options are required. This makes the options class very simple. All that is necessary is to define the default styles.
<pre>from gramps{{RWT_ReportOptions.gen.plug.report import Reportfrom gramps.gen.plug.report import ReportOptionsfrom gramps.gen.lib import Personfrom gramps.gen.plug import docgenfrom gramps.gen.const import GRAMPS_LOCALE as glocale_ = glocale.translation.gettext  class DbSummaryOptions(ReportOptions):  def __init__(self, name, database):  ReportOptions.__init__(self, name, database)  def make_default_style(self, default_style):  # Define the title paragraph, named 'DBS-Title', which uses a # 18 point, bold Sans Serif font with a paragraph that is centered  font = docgen.FontStyle() font.set_size(18) font.set_type_face(docgen.FONT_SANS_SERIF) font.set_bold(True)  para = docgen.ParagraphStyle() para.set_header_level(1) para.set_alignment(docgen.PARA_ALIGN_CENTER) para.set_font(font) para.set_description(_('The style used for the title of the page.'))  default_style.add_paragraph_style('DBS-Title', para)  # Define the normal paragraph, named 'DBS-Normal', which uses a # 12 point, Serif font.  font = docgen.FontStyle() font.set_size(12) font.set_type_face(docgen.FONT_SERIF)  para = docgen.ParagraphStyle() para.set_font(font) para.set_description(_('The style used for normal text'))  default_style.add_paragraph_style('DBS-Normal', para) </pre>py}}
So create now file '''report.py''' and copy there the above code.
64
edits