Changes

Jump to: navigation, search

Gramplets

48 bytes added, 00:51, 28 January 2013
m
Hello World: -
{{man warn|Warning:|Technical details about Gramplets for Developers. If you are interested in using Gramplets, please see [[Gramps 4.0 Wiki Manual - Gramplets]].}}
A '''Gramplet''' is a type of GRAMPS Gramps plugin. Gramplets are mini-view that is designed to be composed with other Gramplets or Views to create a way to see your Family Tree that is just right for you. In fact, Gramplets can be made to do just about anything that you want.
[[File:GrampletsGrampletsDefault-40.png|400px|thumb|right|Gramplet]]
You can read more about the gpr.py file in [[Addons development]] and the [http://svn.code.sf.net/p/gramps/code/trunk/gramps/gen/plug/_pluginreg.py source code implementation].
If you place these files in '''your personal plugins directory''' (usually in ''.gramps/grampsxx/plugins/gramplet/'' ), and then restart GRAMPSGramps, you will be able to create this Gramplet. On the Gramplet View, right-click in an open area and select the "Hello World Gramplet". You should then see:
[[File:HelloWorldGramplet-40.png|thumb|left|Hello World Gramplet]] {{-}}
=== Explanation ===
The main work of a Gramplet is performed in a function, or a class. In this very simple example, a function '''init''' is defined that takesa single argument, gui. The function simply sets the gui's text area to be "Hello World!", and that's it. It does this just once, and never changes.
Before a plugin can be used, it needs to be "registered". You call the register function with a number of named-arguments. There are a number of named-arguments that you can provide, including: name, height, content, title, expand, state, and data. We will explore those in detail, below.
* '''status''': STABLE or UNSTABLE
* '''version''': a string with 2 dots (such as "1.23.14") representing the version number
* '''gramps_target_version''': a string with 2 dots representing the version of GRAMPS Gramps that this gramplet was written for
* '''help_url''': the title of the wiki page that describes the gramplet
</pre>
The method main() can be written as a normal Python method, or it can be written to run nicely in parallel with other GRAMPS Gramps code. To make it run nicely in parallel, you should issue a '''yield True''' every once in a while. For example:
<pre>
# File: Widget.py
from gettext import gettext as _
from gramps.gen.plug import Gramplet
import gtk
</pre>
In fact, with Python, gtk, and cairo, you can make your own widgets that do pretty much anything and look very nice. Here is an example adding a Cairo Clock (which really keeps time) to GRAMPS Gramps 3.4 : [https://gramps-addons.svn.sourceforge.net/svnroot/gramps-addons/branches/gramps34/download/ClockGramplet.addon.tgz ClockGramplet.addon.tgz]
Here it is on the Gramplet view:
* '''get_option(TEXT)'''
== Predifined Predefined Properties ==
There are a number of preset properties:
To learn more about writing a Gramplet, it is suggested to look at the existing Gramplets. You can see a complete list of the Gramplet source code here:
* [http://svn.code.sf.net/p/gramps/code/branches/maintenance/gramps34/src/plugins/gramplet/ GRAMPS Gramps 3.4 Gramplets]* [http://svn.code.sf.net/p/gramps/code/trunk/gramps/plugins/gramplet/ GRAMPS Gramps Trunk Gramplets]
Click on a filename, and then "(to view)" to see the source code of that Gramplet.
[[Category:Developers/General]]

Navigation menu