Changes

Jump to: navigation, search

Gramplets

2,324 bytes added, 16:17, 17 July 2022
m
no edit summary
<!--{{languages|Gramplets}}-->
{{man warn|Warning:|This section contains technical details about programming Gramplets and is intended for Developers. <br><br>'''If you are interested in using Gramplets, please see the [[Gramps_5.1_Wiki_Manual_-_Gramplets|user manual section on gramplets]]'''.}}
A '''Gramplet''' is a type of Gramps plugin. Gramplets are mini-view that is views designed to be composed composited 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:DashboardCategory-DashboardView-default-gramplets-50.png|450px|thumb|right|Default Gramplets on Dashboard]]
= Gramplet Interface =
 
Gramplet only operate after being added to a view. Add (or remove and restore) to the [[Gramps_5.1_Wiki_Manual_-_Main_Window#Bottombar_and_Sidebar|sidebar or bottombar]] of a view by clicking the {{man button|&or;}} (''Down Arrowhead'' button) also known as the '''Gramplet Bar Menu''' at the far top right of the bars titles, and then using one of the options from the drop-down menu. In the Dashboard view, this menu is accessed by right-clicking in-between gramplets in the main view.
 
Gramplet can dramatically degrade the performance of Gramps. Some Gramplets consume huge amounts of memory, processor power and move a lot of data through storage. Don't keep a Gramplet active when it isn't being used!
 
When the view is not active or Gramplet tab is not the foremost in the splitbar, the Gramplet is inactive. A detached (undocked) Gramplet is always active.
= The user interface for a Gramplet Interface =is left completely to the discretion of the developer. Detach/undock a Gramplet to reveal the "Help" button. Explore the Configure options after adding a Gramplet.
== Are Gramplets and 'plug-ins' the same thing? ==
There are 6 main kinds of plugins:
# '''Gramplets''': interactive views for moving, analysing, displaying, etc.
There are two plugin directories: a global/system one, and a private/personal one. You can easily create a plugin by simply putting a file in plugins folder of your personal plugin directory [[Gramps_5.1_Wiki_Manual_-_User_Directory|User Directory]] (usually in ''.gramps/grampsxx/plugins/gramplet/'' ).
== Hello World ==
== Hello World, with Class ==
Here is the same functionality again, but this time as a class (and the 'Hello World' text in Spanish):
<pre>
# File: HolaMundoHelloWorld2.py
from gramps.gen.plug import Gramplet
class HolaMundoGrampletHelloWorldGramplet(Gramplet):
def init(self):
self.set_text("¡Hola MundoHello world!")
</pre>
<pre># File: HolaMundoHelloWorld2.gpr.py
register(GRAMPLET,
id="Hola Mundo Hello World2 Gramplet", name=_("Hola Mundo Hello World2 Gramplet"), description = _("un programa que dice a program that says 'Hola MundoHello World'"),
version="0.0.1",
gramps_target_version="5.1",
status = STABLE,
fname="HolaMundoHelloWorld2.py",
height = 20,
gramplet = 'HelloWorldGramplet',
gramplet_title=_("Muestra Sample Gramplet"), help_url="Muestra Gramplet5.1_Addons#Addon_List" )</pre>
This is the '''recommended method''' of creating a Gramplet. The following details describe the properties and methods of this class.
== Register Options ==
* '''<code>GRAMPLET</code>''': the first argument is the keyword GRAMPLET* '''<code>id</code>''': the identifying name of the gramplet, unique among all plugins* '''<code>name</code>''': the translated gramplet's name* '''<code>height</code>''': the minimum (or maximum) height of the gramplet in normal mode* '''<code>fname</code>''': the name of your gramplet file* '''<code>gramplet</code>''': the name of the function or class in fname that creates the gramplet* '''<code>gramplet_title</code>''': the default gramplet title; user changeable in ''Configure View''* '''<code>status</code>''': STABLE or UNSTABLE* '''<code>version</code>''': a string with 2 dots (such as "1.23.14") representing the version number* '''<code>gramps_target_version</code>''': a string with 2 dots representing the version of Gramps that for which this gramplet was written . Only gramplets matching the installed version will be available forinstallation. * '''<code>help_url</code>''': the title of the wiki page that describes the gramplet. <br />If the help_url starts with <code>http://</code> then that fully qualified URL will be used as is. Otherwise, the paths will be interpreted as relative to <code>http&#58;//gramps-project.org/wiki/index.php?title=</code> base URL. The base URL will be prepended to the '''help_url''' and may get a language extension (such as <code>/nl</code> ) appended at the end, if the operating language is one of '''nl''' '''fr''' '''sq''' '''mk''' '''de''' '''fi''' '''ru''' '''sk'''. You should '''''not''''' use the <code>_(</code> <code>)</code> translate function around the '''<code>help_url</code>''' string, unless you specifically intend to create web pages named with the translated string.
At the bare minimum, you need to have the above 10 11 options when registering your Gramplets.
In addition, you can use the following as well:
* '''<code>detached_width</code>''': the size in pixels of the minimum and default detached height* '''<code>detached_height</code>''': the size in pixels of the minimum and default detached height* '''<code>expand</code>''': whether or not the Gramplet should expand to fill the column, if it can* '''<code>description</code>''': a description of the grampletGramplet
== Core Methods ==
* [https://github.com/gramps-project/gramps/blob/master/gramps/gen/plug/_gramplet.py master/gramps/gen/plug/_gramplet.py] - Base class for non-graphical gramplet code.
 
= See also =
* [[Addons development]] - for Gramps 4.2 and later
** [[Addons development old]] - for Gramps 3.2 to 4.1
* [[Writing a plugin]] - for Gramps version 3.2 and earlier
[[Category:Addons]]
4,529
edits

Navigation menu