Perhaps the original 157 lines of the clock.py
sample code by Ralph Glass could be re-adapted to make the ClockGramplet add-on into a solid foundation for a viable new Developer tutorial?
I keep beginning new experiment in learning Gramps code, generally by examining add-ons … and continually run into road-blocks.
My hope was to find a quickstart tutorial to ‘onboard’ a Programmer in working within the Gramps GUI. (Bypassing the Gramps data model side because that is too much to swallow in one gulp. The Gramps data manipulation and formatting experiments could be worked into a separate SuperTool or Python Shell tutorial.)
The QuickStart progression of steps would completely bypass GitHub and the development environment.
It could consist of:
- being provided a working sample of a simple Python source module (Code that would run in a Python IDE if they had one installed outside Gramps.) The sample would show enough functionality to be interesting. (Something with more functionality than “Hello World!”)
- Then be shown a compatible example of that code with any tweaks needed to make run within the Python Shell gramplet. (Path changes, library changes, variable naming conventions, etc.)
- Then an adapted example of that Python Shell gramplet code MINIMALLY changed to run encapsulated in the gramplet shell (with
.gpr.py
file). - Optionally, an optimized version (but this could be the final outcome of the tutorial. Still, it is nice to have a working version to compare against if you screw up during the tutorial.)
These 3 revisions can be used to write a tutorial process of making the a python module something that can be run within the Gramps GUI. It would include creating a full-featured Gramps Plugin Registration file and whatever shell encapsulation was needed to make that code run as a Gramplet (that might possibly mean some tweaks for compatibility with other OSes)
There would be a host of follow-on lessons:
- how to insert Log and Warning messages (with introduction of using the Console to allow debugging feedback)
- exploration of supporting internationalization
- help file linking (of a GitHub-style README.md or a Wiki Addon:UserDoc)
- CLI compatibility (parameter passing
- adding Configuration options
- Context menus (connecting to resources outside Gramps: OS Clipboard, links to external websites, etc.)
- working with Glade files
- connecting to the Gramps Data Model and methods would be a separate tutorial track
The Gramplets wiki article buries a reader in a discouraging and excessive amount of preliminary detail. But eventually, it suggests that an example for making a simple Gramplet which purportedly looked nice (one that didn’t actually have to touch the Tree data tables) was the Cairo-Clock add-on gramplet. The python code provides live feedback proving that it is operational and does not need to touch the Gramps data model. The description of “looks nice” is in comparison to Text Terminal style presentation of graph data. It is about as primitive as possible while still using drawn objects.
The credits led me to believe that the ClockGramplet.py
was Doug Blank’s direct encapsulation of Ralph Glass’s clock.py
for the Linux community.
Unfortunately, that sample didn’t meet most of my expectations as good sample code.
It jumped too many steps at once. Doug’s adaptation bore little resemblance to the structure of Raph’s original code and was without any helpful comments describing why the changes were inserted. A side-by-side comparison was not edifying. There are no line-by-line explanations of the new code produced for the separate Gramps Plugin Registration file. Nor is there any suggestion of how to troubleshoot registration conflicts or loading failures.
As a tutorial, the ClockGramplet is non-starter and a dead end.
The drawback to redeveloping on this foundation is that: this clock is probably too plain to draw in new UX and UI developers to the next stage … visually, the graphics are an outmoded example of Cairo.