Changes

From Gramps

Report-writing tutorial

271 bytes added, 13:31, 29 November 2025
Registering the report: Edited the content and adjusted hyperlinks
===Registering the report===
* Registration is set into a ''<name>.gpr.py'' file
* The registration consists from a single call to [https://www.gramps-project.org/docs/gen/gen_plug.html#gramps.gen.plug._pluginreg.register register()] function* Registration should define internal name <code>id</code> of the report (preferably, single string with non-special ascii characters, usable for report identification from the command line and in the options storage, as well as for forming sane filename for storing its own styles). * It should also define the report's...** <code>category </code> (text/graphics/code)** translated translatable <code>name </code> (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>.** The <code>report_modes</code> argument is set to a list of zero or more of the following modes: *** REPORT_MODE_GUI (available for Gramps running in a window, graphical user interface)*** REPORT_MODE_BKI (available as a book report item)*** REPORT_MODE_CLI (available for the command line interface)** Finally, both report class <code>reportclass</code> and options class <code>optionsclass</code> names should be passed to registration. Descriptions of the other arguments of [https://www.gramps-project.org/docs/gen/gen_plug.html#gramps.gen.plug._pluginreg.register register()] function can be found [https://www.gramps-project.org/docs/gen/gen_plug.html#module-gramps.gen.plug._pluginreg here]. Here's the [[Quick_Views#Analysis:_registering_the_report| registration]] statement for our report:
<pre>
from gramps.gen.plug._pluginreg import registerfrom gramps.gen.plug._pluginreg import REPORT, STABLE, CATEGORY_TEXTfrom gramps.gen.plug._pluginreg import REPORT_MODE_GUI, REPORT_MODE_CLI*
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
)
</pre>
There are arguments for the report class and options class. The <tt>report_modes</tt> argument is set to a list of zero or more of the following modes:
 
* REPORT_MODE_GUI (available for Gramps running in a window, graphical user interface)
* REPORT_MODE_BKI (available as a book report item)
* REPORT_MODE_CLI (available for the command line interface)
 
The list should only include those options which are valid for this report.
 
The rest of the options should be self-explanatory.
Copy the above code into '''report.gpr.py''' file.
====Book ReportRemark regarding book report mode ====
To turn a report into one that will work as a book report, you may need add REPORT_MODE_BKI to the list of <code>report_modes</code> above. Also you have to add additional code to <code>write_report()</code> method of the Report class, similar to the followingcode below:
<pre>
</pre>
See an existing book report reports for more details. DO NOT copy the above code into '''report.py''' file!since we do not intend to use our report in Book mode.
== Manually installing your report ==
64
edits

Navigation menu