Jump to: navigation, search

Report-writing tutorial

676 bytes added, 12:08, 12 September 2021
Typo in code variable name : "fist" instead of "first"
{{languages|Report-writing tutorial}}
This tutorial covers the basics of writing a simple report using the Gramps report infrastructure. It covers the process of handling options, building a document and creating the report.
* The most common surname
As of {{man tip|From Gramps version 3.2, there is also a |A [[Simple Access API|simple access]] database [ API] available, with accompanying [[Quick Views]], [[Gramplets]] and [[Addons development|Addons]].}}
A report can potentially be generated as a standalone report, as a Gramps Book item, and as a command line report. The registration determines which modes are enabled for a given report. The report class does not have to know anything about the mode. The options class is there to provide options interface for all available modes.
* [[Report-writing_tutorial#Registering_the_report]]
Paragraph and font styles are defined in the <tt>make_default_style()</tt> function of the options class. The paragraphs are grouped into a <tt>StyleSheet</tt>, which the <tt>make_default_style()</tt> function defines. For the example report (<tt>DbSummary</tt>), the paragraph styles are defined as below:
{{stub}}<!-- need to check code is correct for Gramps 5.1.x -->
compare to <code>gramps\plugins\textreport\</code> starting at [ line 297]
def make_default_style(self, default_style):
# Options specific for this report
self.options_dict = {
'my_fist_optionmy_first_option' : 0,
'my_second_option' : '',
self.options_help = {
'my_fist_optionmy_first_option' : ("=num","Number of something",
[ "First value", "Second value" ],
===Defining the Report Options class===
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.
** translated name (the one to display in menus)
** modes that should be enabled for the report (standalone, book item, command line)
* If the report requires an active person to run, then <code>require_active </code> should be set to <code>True</code>.
* Finally, both report class and options class should be passed to registration.
description = _("Produces a ..."),
version = '1.0',
gramps_target_version = '35.21',
status = STABLE,
fname = '',
See an existing book report for more details.
== Manually installing your report ==
Install in the plugins directory of your Gramps user directory.
== Example output ==
Start Gramps and your tutorial report will be available from the reports menu as ....
Run the report and this is what the output looks like ....
==See also==
* [[Report_API|Report API]]
* [[Report_Generation|Report Generation]] (describing output format options)* [[Gramps_Data_Model|Gramps Data Model]]
[[Category: Plugins]]

Navigation menu