Changes

Jump to: navigation, search

Quick Views

594 bytes added, 05:12, 10 May 2020
m
Where to store my Quick View
[[File:QuickViewReport-EditPerson-context-menu-popup-50.png|thumb|right|450px|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, etc..
They are easy to make by users, even People with limited coding knowledgeshould be able to make them[[File:QuickViewReport-EditPerson-context-menu-popup-50.png|thumb|right|450px|Quick View context menu on Person Editor]]
==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 in with Gramps 3.0 a new tool has been was constructed: the {{man label|Quick Views. 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.
==Where to store my quick reportQuick View==A quick report Quick View is one single file. You can store it 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 directory subdirectory '''.gramps'''. In this directory you will find the '''plugins''' directorysubdirectory. 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
 
* See [[Gramps_{{man version}}_Wiki_Manual_-_User_Directory|Wiki Manual Appendix D - User Directory]]
==Example 1==
{{-}}
Create ==== siblings.gpr.py ====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: <pre>#------------------------------------------------------------------------# File: siblings.gpr.py#------------------------------------------------------------------------ register(QUICKREPORT, id = 'siblings', name = _("Siblings - Example Quick View"), description = _("Display a person's siblings."), version = '1.0', gramps_target_version = '5.1', status = STABLE, fname = 'siblings.py', authors = ["Your Name Here"], authors_email = ["Your @ Email address here"], category = CATEGORY_QR_PERSON, runfunc = 'run' )</pre>
{{stub}}==== siblings.py ====Now create a python file named <!--this code is old, needs to be changed >siblings.py</code> and tested-->add the following content:
<pre>
#------------------------------------------------------------------------
# File: Siblingssiblings.py
#------------------------------------------------------------------------
from gramps.gen.simple import SimpleAccess, SimpleDoc
from gramps.gui.plug.quick import QuickTable
from gramps.gen.ggettext const import gettext GRAMPS_LOCALE as glocale_= glocale.translation.gettext
def run(database, document, person):
document.has_data = True
stab.write(sdoc)
</pre>
 
You will also need a Gramps registration file:
 
<pre>
#------------------------------------------------------------------------
# File: Siblings.gpr.py
#------------------------------------------------------------------------
 
register(QUICKREPORT,
id = 'siblings',
name = _("Siblings"),
description = _("Display a person's siblings."),
version = '1.0',
gramps_target_version = '4.1',
status = STABLE,
fname = 'siblings.py',
authors = ["Donald N. Allingham"],
authors_email = ["[email protected]"],
category = CATEGORY_QR_PERSON,
runfunc = 'run'
)
</pre>
===Analysis: registering the report===
Let's analyse the [[Quick_Views#siblings.gpr.py|siblings.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|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.
===Analysis: the run function===
Now lets analyse the [[Quick_Views#siblings.py|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:
<centercode>'''run(database, document, person)'''</centercode>
So, your report received receives from gramps 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
<code>def run(database, document, person):</code>
===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 Access API|Simple Database API]].  So, the following code:
<pre>
</pre>
Note that we use '''an underscore (<code>_''' for </code>) to indicate every string for that requires translation, which comes from the line:
<pre>
4,610
edits

Navigation menu