Difference between revisions of "Quick Views"

From Gramps
Jump to: navigation, search
m (See also)
 
(74 intermediate revisions by 9 users not shown)
Line 1: Line 1:
Quick reports are reports that are available in the context menu's of person, family, ...
+
[[File:QuickViewReport-EditPerson-context-menu-popup-50.png|thumb|right|450px|Quick View context menu on Person Editor]]
  
They are easy to make by users, even with limited coding knowledge.
+
Quick Views (previously called ''Quick reports'' but show up in "Available Gramps Update for Addons" as ''Quickreport'') are reports that are available in the context menu's of person, family, et cetera. There are a set of [[Gramps_{{man version}}_Wiki_Manual_-_Reports_-_part_8#Quick_Views|built-in Quick Views]] that can be expanded with add-on QuickView type plug-ins.
 +
 
 +
People with limited coding knowledge should be able to make them.
  
 
==Introduction==  
 
==Introduction==  
[[Image:Gramps_quick_report_edit.png|thumb|right|Quick Report context menu on Person Editor]]
+
Many users want to produce a report quickly for their specific needs, but are hindered by the fact they do not want to learn python fully, nor the intricacies of a complicated program like Gramps.
Many users want to produce a report quickly for their specific needs, but are hindered by the fact they do not want to learn python fully, nor the intricacies of a complicated program like GRAMPS.  
+
 
 +
For them, starting with Gramps 3.0 a tool was constructed: the {{man label|Quick Views}} short textual reports that the user can register with Gramps, so they automatically appear in the context menu's.
  
For them, starting in GRAMPS 3.0 a new tool has been constructed: the quick reports. These reports are short textual reports that the user can register with GRAMPS, so they automatically appear in the context menu's.
 
 
Accompanying this, a [[Simple Access API|simple database access]] and simple document interface has been constructed, so as to hide as much complexity as possible.
 
Accompanying this, a [[Simple Access API|simple database access]] and simple document interface has been constructed, so as to hide as much complexity as possible.
  
==Where to store my quick report==
+
==Where to store my Quick View==
A quick report is one single file. You can store it in your plugins directory. Go into your home folder and go to the hidden directory '''.gramps'''. In this directory you will find the '''plugins''' directory. Just add your plugin there, and it will appear within GRAMPS.  
+
A Quick View is normally composed of two files in its own subdirectory, that are stored under your ''[[Gramps_{{man version}}_Wiki_Manual_-_User_Directory|User]]'' plugins directory. Go into your home folder and go to the hidden subdirectory '''.gramps'''. In this directory you will find the '''plugins''' subdirectory. Just add your plugin there, and it will appear within Gramps.  
  
 
For the terminal users, you can get there as follows:
 
For the terminal users, you can get there as follows:
 
  cd ~/.gramps/grampsxx/plugins
 
  cd ~/.gramps/grampsxx/plugins
 +
 +
* See [[Gramps_{{man version}}_Wiki_Manual_-_User_Directory|Wiki Manual Appendix D - User Directory]]
  
 
==Example 1==
 
==Example 1==
 
===Code===
 
===Code===
[[Image:Gramps_quick_report_view.png|thumb|right|Quick Report context menu on Person View]]
+
[[File:QuickViewReport-people-context-menu-popup-50.png|thumb|right|450px|Quick View context menu on Person View]]
 +
[[File:Siblings-quick-report-result-34.png|thumb|right|450px|Quick View Report example result output]]
 +
 
 
How better than to learn something than using an example?  
 
How better than to learn something than using an example?  
Here it goes. We want a report to show all siblings of a person. That is, brothers and sisters from '''all''' families the person is part of. The quick report is then the following:
 
  
  26 from Simple import SimpleAccess, SimpleDoc
+
Here it goes. We want a report to show all siblings of a person.
   27 from gettext import gettext as _
+
 
  28 from PluginUtils import register_quick_report
+
That is, brothers and sisters from '''all''' families the person is part of.
  29 from ReportBase import CATEGORY_QR_PERSON
+
 
  30
+
The quick report is then the following:
  31 # define the formatting string once as a constant. Since this is reused
+
 
  32
+
{{-}}
  33 __FMT = "%-30s\t%-10s\t%s"
+
<span id="siblings.gpr.py"></span>
  34
+
==== siblings2.gpr.py ====
  35 def run(database, document, person):
+
You first need a Gramps registration (<code>*.gpr.py</code>) file so create a python file named <code>Siblings.gpr.py</code> and add the following content:
  36     """
+
<pre>
  37     Loops through the families that the person is a child in, and display
+
#------------------------------------------------------------------------
  38     the information about the other children.
+
# File: siblings.gpr.py
  39     """
+
#------------------------------------------------------------------------
  40
+
 
  41     # setup the simple access functions
+
register(QUICKREPORT,  
  42     sdb = SimpleAccess(database)
+
    id   = 'siblings2',
  43     sdoc = SimpleDoc(document)
+
    name  = _("Siblings2 - Example Quick View"),
  44
+
    description =  _("Display a person's siblings."),
  45     # display the title
+
    version = '0.1',
  46     sdoc.title(_("Siblings of %s") % sdb.name(person))
+
    gramps_target_version = '5.2',
  47     sdoc.paragraph("")
+
    status = STABLE,
  48
+
    fname = 'siblings2.py',
  49    # display the header of a table
+
    authors = ["Your Name Here"],
  50    sdoc.header1(__FMT % (_("Sibling"), _("Gender"), _("Birth Date")))
+
    authors_email = ["Your @ Email address here"],
  51
+
    category = CATEGORY_QR_PERSON,
  52     # grab our current id, so we can filter the active person out
+
    runfunc = 'run'
  53     # of the data
+
  )
  54
+
</pre>
  55     gid = sdb.gid(person)
+
 
  56
+
<span id="siblings.py"></span>
  57     # loop through each family in which the person is a child
+
==== siblings2.py ====
  58     for family in sdb.child_in(person):
+
Now create a python file named <code>siblings.py</code> and add the following content:
  59
+
 
  60         # loop through each child in the family
+
<pre>
  61         for child in sdb.children(family):
+
#------------------------------------------------------------------------
  62
+
# File: siblings2.py
  63             # only display if this child is not the active person
+
#------------------------------------------------------------------------
  64             if sdb.gid(child) != gid:
+
 
  65                 sdoc.paragraph(__FMT % (
+
from gramps.gen.simple import SimpleAccess, SimpleDoc
  66                        sdb.name(child),
+
from gramps.gui.plug.quick import QuickTable
  67                         sdb.gender(child),
+
from gramps.gen.const import GRAMPS_LOCALE as glocale
  68                         sdb.birth_date(child)))
+
_ = glocale.translation.gettext
  69
+
 
  70 #------------------------------------------------------------------------
+
def run(database, document, person):
  71 #
+
     """
  72 #
+
     Loops through the families that the person is a child in, and display
  73 #
+
     the information about the other children.
  74 #------------------------------------------------------------------------
+
     """
  75 register_quick_report(
+
 
  76    name = 'a_unique_name_with_no_spaces',
+
     # setup the simple access functions
  77    category = CATEGORY_QR_PERSON,
+
     sdb = SimpleAccess(database)
  78     run_func = run,
+
     sdoc = SimpleDoc(document)
  79    translated_name = _("Siblings"),
+
 
  80    status = _("Stable"),
+
     # display the title
  81    description= _("Display a person's siblings."),
+
     sdoc.title(_("Siblings of %s") % sdb.name(person))
  82    author_name="your name",
+
     sdoc.paragraph("")
  83    author_email="your email"
+
 
  84    )
+
     # grab our current id, so we can filter the active person out
 +
     # of the data
 +
 
 +
     gid = sdb.gid(person)
 +
 
 +
 
 +
    stab = QuickTable(sdb)
 +
    sdoc.header1(_("Siblings"))
 +
    stab.columns(_("Person"),
 +
                _("Gender"),
 +
                _("Date"))
 +
 
 +
     # loop through each family in which the person is a child
 +
     for family in sdb.child_in(person):
 +
 
 +
         # loop through each child in the family
 +
         for child in sdb.children(family):
 +
 
 +
             # only display if this child is not the active person
 +
             if sdb.gid(child) != gid:
 +
                 stab.row(child,
 +
                         sdb.gender(child),
 +
                         sdb.birth_date(child))
 +
                document.has_data = True
 +
     stab.write(sdoc)
 +
</pre>
  
 
===Analysis: registering the report===
 
===Analysis: registering the report===
The above code is GPL licensed, written by Don.
+
 
Let's analyse this. We start at the bottom where the report is registered with '''register_quick_report'''. This is the function GRAMPS will look for in your file. You need to give:
+
Let's analyse the [[Quick_Views#siblings2.gpr.py|siblings2.gpr.py]] file above. We start at the bottom where the report is registered with '''register'''. This is the function Gramps will look for in your file. You need to give:
*{{man label|name}} = a unique name: a name GRAMPS identifies the plugin with, don't use spaces or strange symbols.
+
*{{man label|name}} = a unique name: a name Gramps identifies the plugin with, don't use spaces or strange symbols. In this case, we add a '2' to the name to avoid conflicts with the built-in [[Gramps_{{man version}}_Wiki_Manual_-_Reports_-_part_8#Siblings|siblings quickview]].
*{{man label|category}} = a special constant indicating where the report will be shown. You can use '''CATEGORY_QR_PERSON''' to see the report on person editor and view, or '''CATEGORY_QR_FAMILY''' to see the report on family editor or view.
+
* [https://github.com/gramps-project/gramps/blob/892fc270592095192947097d22a72834d5c70447/gramps/gen/plug/_pluginreg.py#L159-L171 {{man label|category}}] = a special constant indicating where the report will be shown. You can use '''CATEGORY_QR_PERSON''' to see the report on person editor and view, or '''CATEGORY_QR_FAMILY''' to see the report on family editor or view. (CATEGORY_QR_DATE is for reports that can be embedded in other reports since there is no "Date" category.)
*{{man label|run_func}} = the function you create in this plugin and that GRAMPS will execute when the user selects your quick report in the menu
+
*{{man label|run_func}} = the function you create in this plugin and that Gramps will execute when the user selects your quick report in the menu
 
* {{man label|translated_name}} = the name of the report as it will appear in the menu
 
* {{man label|translated_name}} = the name of the report as it will appear in the menu
* {{man label|status}} = is your report '''Stable''' or '''Unstable'''. Not used at the moment. On distributing GRAMPS we only include stable reports.
+
* [https://github.com/gramps-project/gramps/blob/892fc270592095192947097d22a72834d5c70447/gramps/gen/plug/_pluginreg.py#L58-L69 {{man label|status}}] = is your report '''Stable''', '''Unstable''', '''Experimental''' and '''Beta'''
*{{man label|description}} = a description of what your plugin does. This appears in a tooltip over the menu
+
* {{man label|description}} = a description of what your plugin does. This appears in a tooltip over the menu
*{{man label|author_name}} = your name
+
* {{man label|author_name}} = your name
*{{man label|author_email}}= your email, so people can congratulate you with your work, or ask for bug fixes...
+
* {{man label|author_email}}= your email, so people can congratulate you with your work, or ask for bug fixes...
 +
 
 +
And beginning with Gramps 5.2 version, there are [https://github.com/gramps-project/gramps/pull/1451 additional registration properties]:
 +
* {{man label|help_url}} = a webpage that will be opened when using the Help
 +
* [https://github.com/gramps-project/gramps/blob/892fc270592095192947097d22a72834d5c70447/gramps/gen/plug/_pluginreg.py#L71-L76 {{man label|audience}}] = filtering options: ‘All’, ‘Developer’ and ‘Expert’.
 +
* {{man label|maintainers}} = name of person currently maintaining the add-on, if different from the author_name
 +
* {{man label|maintainers_email}} = email of person currently maintaining the add-on, if different from the author_email
 +
* [https://github.com/gramps-project/gramps/blob/892fc270592095192947097d22a72834d5c70447/gramps/gen/plug/_pluginreg.py#L297-L299 {{man label|requires_mod}}], [https://github.com/gramps-project/gramps/blob/892fc270592095192947097d22a72834d5c70447/gramps/gen/plug/_pluginreg.py#L300-L303 {{man label|requires_gi}}], [https://github.com/gramps-project/gramps/blob/892fc270592095192947097d22a72834d5c70447/gramps/gen/plug/_pluginreg.py#L304-L306 {{man label|requires_exe}}] = if the addon has prerequisites.
  
 
===Analysis: the run function===
 
===Analysis: the run function===
If the user clicks in the quick report menu on your report, the run function is executed with three parameters:
 
  
<center>
+
Now lets analyse the [[Quick_Views#siblings.py|siblings.py]] file.
'''run_function(database, document, handle)'''
+
 
</center>
+
If the user clicks in the quick view report menu on your report, the run function is executed with the following three parameters:
  
So, your report recieved from gramps the database on which to work, the document on which to write, and the handle (=unique identifier) of the object the user is on. For a person quick report, this is a person handle, for family, a family handle.
+
<code>run(database, document, person)</code>
  
 +
So, your report receives from Gramps the currently opened database name on which to work, the document on which to write, and the person of the object the user is on. For a person quick view report, this is a person, for family, a family.
  
 
In this example, the function called is  
 
In this example, the function called is  
def run(database, document, person):
+
 
 +
<code>def run(database, document, person):</code>
  
 
===Analysis: accessing the data===
 
===Analysis: accessing the data===
Now that your plugin runs, you need to open the database, start the document, access data, and write it out.  
+
Now that your plugin runs, you need to open the database, start the document, access data, and write it out. We do this using the [[Simple Access API|Simple Database API]].  
We do this using the [[Simple Access API|Simple Database API]]. So,  
+
 
  41    # setup the simple access functions
+
So, the following code:
  42    sdb = SimpleAccess(database)
+
 
  43    sdoc = SimpleDoc(document)
+
<pre>
 +
# setup the simple access functions
 +
sdb = SimpleAccess(database)
 +
sdoc = SimpleDoc(document)
 +
</pre>
 +
 
 
prepares everything. Then we write a title on the document, an empty line under it, and a header, with the title, paragraph and header function:
 
prepares everything. Then we write a title on the document, an empty line under it, and a header, with the title, paragraph and header function:
  45    # display the title
 
  46    sdoc.title(_("Siblings of %s") % sdb.name(person))
 
  47    sdoc.paragraph("")
 
  49    # display the header of a table
 
  50    sdoc.header1(__FMT % (_("Sibling"), _("Gender"), _("Birth Date")))
 
Note that we use '''_''' for every string for translation, which comes from the line
 
  27 from gettext import gettext as _
 
You can replace this by
 
  46    sdoc.title("Siblings of %s" % sdb.name(person))
 
to just try it out for yourself, without a translation option.
 
  
As we will write a list, it is usefull to define the structure of your text one time, and reuse this. That is the '''__FMT''' constant, defined as
+
<pre>
  33 __FMT = "%-30s\t%-10s\t%s"
+
# display the title
So we have 30 spaces for the Sibling field, then a tab ('''\t'''), then 10 spaces for the Gender, another tab and the last stringfield for the birth date.
+
sdoc.title(_("Siblings of %s") % sdb.name(person))
 +
sdoc.paragraph("")
 +
</pre>
 +
 
 +
Note that we use an underscore (<code>_</code>) to indicate every string that requires translation, which comes from the line:
 +
 
 +
<pre>
 +
from gramps.gen.ggettext import gettext as _
 +
</pre>
  
 
Everything is set up, now we write out the lines with all the siblings, leaving out the active person himself, as he is in the title field!
 
Everything is set up, now we write out the lines with all the siblings, leaving out the active person himself, as he is in the title field!
  52    # grab our current id, so we can filter the active person out
+
 
  53    # of the data
+
<pre>
  54
+
# grab our current id, so we can filter the active person out
  55    gid = sdb.gid(person)
+
# of the data
  56
+
 
  57    # loop through each family in which the person is a child
+
gid = sdb.gid(person)
  58    for family in sdb.child_in(person):
+
 
  59
+
# loop through each family in which the person is a child
  60        # loop through each child in the family
+
for family in sdb.child_in(person):
  61        for child in sdb.children(family):
+
 
  62
+
    # loop through each child in the family
  63            # only display if this child is not the active person
+
    for child in sdb.children(family):
  64            if sdb.gid(child) != gid:
+
 
  65                sdoc.paragraph(__FMT % (
+
        # only display if this child is not the active person
  66                        sdb.name(child),
+
        if sdb.gid(child) != gid:
  67                        sdb.gender(child),
+
            stab.row(child,
  68                        sdb.birth_date(child)))
+
                    sdb.gender(child),
 +
                    sdb.birth_date(child))
 +
            document.has_data = True
 +
stab.write(sdoc)
 +
</pre>
  
 
Here, the easy access classes from the [[Simple Access API]] have been used to quickly achieve what we want.
 
Here, the easy access classes from the [[Simple Access API]] have been used to quickly achieve what we want.
  
 
==Example 2==
 
==Example 2==
A second example can be found in the GRAMPS code. See [http://gramps.svn.sourceforge.net/viewvc/gramps/trunk/src/plugins/quickview/all_events.py?view=markup all_events.py]. In this report, all events for a person are printed, and all events for a family. Two quick reports are hence registered, one for person, and one for family.
+
 
 +
A second example can be found in the Gramps code. See [https://github.com/gramps-project/gramps/blob/master/gramps/plugins/quickview/all_events.py all_events.py]. In this report, all events for a person are printed, and all events for a family. Two quick reports are hence registered, one for person, and one for family.
  
 
==Notes==
 
==Notes==
  
The possibilities are enormous. If you are an experienced hacker, there is no need to limit yourself to the simple database API. Also, if you make a real report, you can at the same time register a quick report with default settings.
+
The possibilities are enormous. If you are an experienced programmer, there is no need to limit yourself to the simple database API. Also, if you make a real report, you can at the same time register a quick report with default settings.
 +
 
 +
See: [https://github.com/gramps-project/gramps/tree/master/gramps/plugins/quickview  https://github.com/gramps-project/gramps/tree/master/gramps/plugins/quickview]
 +
 
 +
=See also=
 +
* [[Gramps_{{man version}}_Wiki_Manual_-_Reports_-_part_8#Quick_Views]]
  
 
[[Category:Developers/General]]
 
[[Category:Developers/General]]
 
[[Category:Developers/Tutorials]]
 
[[Category:Developers/Tutorials]]
 
[[Category: Plugins]]
 
[[Category: Plugins]]
 +
[[Category:Reports]]
 +
[[Category:Views]]

Latest revision as of 21:45, 10 March 2024

Quick View context menu on Person Editor

Quick Views (previously called Quick reports but show up in "Available Gramps Update for Addons" as Quickreport) are reports that are available in the context menu's of person, family, et cetera. There are a set of built-in Quick Views that can be expanded with add-on QuickView type plug-ins.

People with limited coding knowledge should be able to make them.

Introduction

Many users want to produce a report quickly for their specific needs, but are hindered by the fact they do not want to learn python fully, nor the intricacies of a complicated program like Gramps.

For them, starting with Gramps 3.0 a tool was constructed: the Quick Views short textual reports that the user can register with Gramps, so they automatically appear in the context menu's.

Accompanying this, a simple database access and simple document interface has been constructed, so as to hide as much complexity as possible.

Where to store my Quick View

A Quick View is normally composed of two files in its own subdirectory, that are stored under your User plugins directory. Go into your home folder and go to the hidden subdirectory .gramps. In this directory you will find the plugins subdirectory. Just add your plugin there, and it will appear within Gramps.

For the terminal users, you can get there as follows:

cd ~/.gramps/grampsxx/plugins

Example 1

Code

Quick View context menu on Person View
Quick View Report example result output

How better than to learn something than using an example?

Here it goes. We want a report to show all siblings of a person.

That is, brothers and sisters from all families the person is part of.

The quick report is then the following:


siblings2.gpr.py

You first need a Gramps registration (*.gpr.py) file so create a python file named Siblings.gpr.py and add the following content:

#------------------------------------------------------------------------
# File: siblings.gpr.py
#------------------------------------------------------------------------

register(QUICKREPORT, 
    id    = 'siblings2',
    name  = _("Siblings2 - Example Quick View"),
    description =  _("Display a person's siblings."),
    version = '0.1',
    gramps_target_version = '5.2',
    status = STABLE,
    fname = 'siblings2.py',
    authors = ["Your Name Here"],
    authors_email = ["Your @ Email address here"],
    category = CATEGORY_QR_PERSON,
    runfunc = 'run'
  )

siblings2.py

Now create a python file named siblings.py and add the following content:

#------------------------------------------------------------------------
# File: siblings2.py
#------------------------------------------------------------------------

from gramps.gen.simple import SimpleAccess, SimpleDoc
from gramps.gui.plug.quick import QuickTable
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext

def run(database, document, person):
    """
    Loops through the families that the person is a child in, and display
    the information about the other children.
    """

    # setup the simple access functions
    sdb = SimpleAccess(database)
    sdoc = SimpleDoc(document)

    # display the title
    sdoc.title(_("Siblings of %s") % sdb.name(person))
    sdoc.paragraph("")

    # grab our current id, so we can filter the active person out
    # of the data

    gid = sdb.gid(person)


    stab = QuickTable(sdb)
    sdoc.header1(_("Siblings"))
    stab.columns(_("Person"), 
                 _("Gender"), 
                 _("Date"))

    # loop through each family in which the person is a child
    for family in sdb.child_in(person):

        # loop through each child in the family
        for child in sdb.children(family):

            # only display if this child is not the active person
            if sdb.gid(child) != gid:
                stab.row(child,
                        sdb.gender(child),
                        sdb.birth_date(child))
                document.has_data = True
    stab.write(sdoc)

Analysis: registering the report

Let's analyse the siblings2.gpr.py file above. We start at the bottom where the report is registered with register. This is the function Gramps will look for in your file. You need to give:

  • name = a unique name: a name Gramps identifies the plugin with, don't use spaces or strange symbols. In this case, we add a '2' to the name to avoid conflicts with the built-in siblings quickview.
  • category = a special constant indicating where the report will be shown. You can use CATEGORY_QR_PERSON to see the report on person editor and view, or CATEGORY_QR_FAMILY to see the report on family editor or view. (CATEGORY_QR_DATE is for reports that can be embedded in other reports since there is no "Date" category.)
  • run_func = the function you create in this plugin and that Gramps will execute when the user selects your quick report in the menu
  • translated_name = the name of the report as it will appear in the menu
  • status = is your report Stable, Unstable, Experimental and Beta
  • description = a description of what your plugin does. This appears in a tooltip over the menu
  • author_name = your name
  • author_email= your email, so people can congratulate you with your work, or ask for bug fixes...

And beginning with Gramps 5.2 version, there are additional registration properties:

  • help_url = a webpage that will be opened when using the Help
  • audience = filtering options: ‘All’, ‘Developer’ and ‘Expert’.
  • maintainers = name of person currently maintaining the add-on, if different from the author_name
  • maintainers_email = email of person currently maintaining the add-on, if different from the author_email
  • requires_mod, requires_gi, requires_exe = if the addon has prerequisites.

Analysis: the run function

Now lets analyse the siblings.py file.

If the user clicks in the quick view report menu on your report, the run function is executed with the following three parameters:

run(database, document, person)

So, your report receives from Gramps the currently opened database name on which to work, the document on which to write, and the person of the object the user is on. For a person quick view report, this is a person, for family, a family.

In this example, the function called is

def run(database, document, person):

Analysis: accessing the data

Now that your plugin runs, you need to open the database, start the document, access data, and write it out. We do this using the Simple Database API.

So, the following code:

# setup the simple access functions
sdb = SimpleAccess(database)
sdoc = SimpleDoc(document)

prepares everything. Then we write a title on the document, an empty line under it, and a header, with the title, paragraph and header function:

# display the title
sdoc.title(_("Siblings of %s") % sdb.name(person))
sdoc.paragraph("")

Note that we use an underscore (_) to indicate every string that requires translation, which comes from the line:

from gramps.gen.ggettext import gettext as _

Everything is set up, now we write out the lines with all the siblings, leaving out the active person himself, as he is in the title field!

# grab our current id, so we can filter the active person out
# of the data

gid = sdb.gid(person)

# loop through each family in which the person is a child
for family in sdb.child_in(person):

    # loop through each child in the family
    for child in sdb.children(family):

        # only display if this child is not the active person
        if sdb.gid(child) != gid:
            stab.row(child,
                     sdb.gender(child),
                     sdb.birth_date(child))
            document.has_data = True
stab.write(sdoc)

Here, the easy access classes from the Simple Access API have been used to quickly achieve what we want.

Example 2

A second example can be found in the Gramps code. See all_events.py. In this report, all events for a person are printed, and all events for a family. Two quick reports are hence registered, one for person, and one for family.

Notes

The possibilities are enormous. If you are an experienced programmer, there is no need to limit yourself to the simple database API. Also, if you make a real report, you can at the same time register a quick report with default settings.

See: https://github.com/gramps-project/gramps/tree/master/gramps/plugins/quickview

See also