Open main menu

Gramps β

Changes

Addon:Python Shell Gramplet

846 bytes added, 14:01, 4 January 2018
m
minor typo on my last edit
{{Third-party plugin}}
[[File:Python-grampletPythonGramplet-interactive-shell-example-4150.png|thumb|right|300px450px|Python Gramplet - Interactive shell example output]]
The Python Gramplet brings up an interactive Python Shell for interpreting python expressions.
*'''uistate''' - Interact with the GUI
When the Python Gramplet is detached you can use select the {{man button|Help}} button to see this page.
==Examples==
[...]
{{out of datestub}}
You can use the Python Shell to interact with people from your database and test Gramps functions:
! Gramps 4.x
| <pre>
> person = db.get_person_from_gramps_id("I01284") > from gen.utils.alive import probably_alive > probably_alive(person, db, Date(1776, 7, 4))
</pre>
|}
|}
This following returns a reference to a loaded Gramplet object on the Event view - useful when developing Gramplets. Note that the Events view must be navigated first, as main views are lazy loading in Gramps 4.
 
{| border="1" style="border-collapse:collapse"
! Gramps 4.x
| <pre>
> evtview = uistate.viewmanager.pages[uistate.viewmanager.page_lookup.get((5,0))]
> # list all TabGramplet objects loaded for Events view
> [child.get_title() for child in evtview.bottombar.get_children()]
['Gallery', 'Citations', 'Notes', 'Attributes', 'References', 'Event PlaceTitle Compare Gramplet']
> # get a reference to my custom Gramplet object
> eptcGramplet = evtview.bottombar.get_children()[5].pui
 
</pre>
|}
[[Category:Plugins]]
[[Category:Developers/General]]
[[Category:Gramplets]]
22
edits