Changes

Jump to: navigation, search

Addons development

221 bytes added, 04:35, 16 February 2018
Test your addon as you develop
{{man warn|Warning:|This page documents the API, methods, and best practices for developing a [[Third-party Addons|Third-party Addon]] for Gramps 4.2 and later. For 4.2 1.x and earlier, see [[Addons_development_oldAddons development old]]. }}
Addons for Gramps can extend the program in many different ways. You can add any of the following [https://github.com/gramps-project/gramps/blob/master/gramps/gen/plug/_pluginreg.py types] of addons:
=== Other pre-requisites ===
{{man warn|These instructions, the make.py script etc.|are designed to operate in a Linux environment. {{man menu|They won't work on Windows without modifications.}}}}
* Gramps uses Python version 3.2 or higher. You must have at least that version installed. If you have installed Gramps 4.2 or higher on your Linux system already, then a sufficient version of Python will be present. If you have more than one version of Python installed, then you must use the correct version for these scripts. On some systems, both Python 2.x and 3.x are installed. It is possible that the normal invocation of <code>python</code> starts up Python 2.x, and that to start up Python 3.x requires invoking with <code>python3</code> or <code>python3.4</code> etc. You can test the version by <code>python –version</code> or <code>python3 –version</code>. If this is so, replace any usage of 'python' in the examples below with the appropriate invocation.
* The make.py used in construction of the addons requires that the LANGUAGE environment variable be set to 'en_US.UTF-8'.
=== Test your addon as you develop ===
 
{{man warn|{{bug|10436}} Symlinks to folders in gramps plugin dir are not scanned}}
 
To test your addon as you develop it is suggested that you insert your NewProjectName plugin into your Gramps user plugin directory with a link to your addon development directory, like so:
Your installed Gramps will search this folder (and subdirectories) for .gpr.py files, and add them to the plugin list.
If you have code that you want to share between addons, you don't need to do anything special. Currently, Gramps adds each directory in which a .gpr.py is found onto the PYTHONPATH which is searched when you perform an import. Thus "import NewProjectName" will work from another addon. You should always make sure you name your addons with a name appropriate for Python imports.
=== Commit your changes ===
For general help on translations in Gramps, see [[Coding for translation]]. However, that will only use translations that come with Gramps, or allows you to contribute translations to the Gramps core. To have your own managed translations that will be packaged with your addon, read the rest of this page.
Note that these instructions will only work for Python strings, if you have a glade file, it will not get translated.
For any addon which you have translations into other languages, you will need to add a way to retrieve the translation. You need to add this to the top of your NewProjectName.py file:
* https://github.com/gramps-project/addons-source - Source code (Git)
* https://github.com/gramps-project/addons - downloadable .tgz files
 
;Gramps Addons site for Gramps 3.2 to Gramps 4.1.
* https://sourceforge.net/p/gramps-addons/ - Source code (SVN) and downloadable .tgz files
[[Category:Developers/General]]

Navigation menu