Changes

Jump to: navigation, search

Quick Views

2,604 bytes added, 10 March
m
See also
[[File:QuickViewReport-EditPerson-context-menu-popup-50.png|thumb|right|450px|Quick Views (previously called ''Quick reports'' but show up in "Available Gramps Update for Addons" as ''Quickreport'') are reports that are available in the View context menu's of person, family, ... on Person Editor]]
They Quick Views (previously called ''Quick reports'' but show up in "Available Gramps Update for Addons" as ''Quickreport'') are easy to make by usersreports that are available in the context menu's of person, even 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 limited coding knowledgeadd-on QuickView type plug-ins.
[[Image:GrampsQuickViewReportEdit-40People with limited coding knowledge should be able to make them.png|thumb|right|400px|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==
===Code===
[[File:QuickViewReport-people-context-menu-popup-4150.png|thumb|right|400px450px|Quick View context menu on Person View]][[File:Siblings -quick -report -result-34.png|thumb|right|400px450px|Quick View Report example result output]]
How better than to learn something than using an example?
{{-}}
Create <span id="siblings.gpr.py"></span>==== siblings2.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 = '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' )</pre>
{{out of date|this <span id="siblings.py"></span>==== siblings2.py ====Now create a python file named <code is old, needs to be changed >siblings.py</code> and tested}}add the following content:
<pre>
#------------------------------------------------------------------------
# File: Siblingssiblings2.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#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. 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]].*[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|translated_name}} = the name of the report as it will appear in the menu
* [https://github.com/gramps-project/gramps/blob/892fc270592095192947097d22a72834d5c70447/gramps/gen/plug/_pluginreg.py#L58-L69 {{man label|status}} ] = is your report '''Stable''' or , '''Unstable'''. Not used at the moment. On distributing Gramps we only include stable reports., '''Experimental''' and '''Beta'''*{{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_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===
If Now lets analyse the user clicks in the quick report menu on your report, the run function is executed with three parameters:[[Quick_Views#siblings.py|siblings.py]] file.
<center>'''If the user clicks in the quick view report menu on your report, the run(database, document, person)'''</center>function is executed with the following three parameters:
<code>run(database, document, person)</code> 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>
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]]

Navigation menu