Configure columns shown in gramplets with table views

In the Danish Facebook Gramps group there was a question on how to change the columns shown of a gramplet in the bottom panel. @emyoulation responded with a reference to Enhanced Citations gramplet.

I have often wanted to be able to change the shown columns of a gramplet in the bottom panel, and while we have a general way of changing the shown columns of the views selected from the Navigator (People, Families, Events etc), it would be nice to have the same or a similar way of changing the shown columns of gramplets.

Right clicking or ctrl clicking the gramplets table view would bring up a window with a list of columns similar to configure columns of the navigator views.

1 Like

Yes. This was the idea behind the PersistentTreeView class.

The initial implementation just remembers the column sizes. We could extend it to also remember column order and perhaps the sort column and sort direction.

A right-click context menu would probably work quite well.

1 Like

To manipulate columns in a Gramplet does require a hack. Using the Events gramplet as an example you can adjust column sizes here

gramps/plugins/gramplet/events.py starting at line 95

    titles = [
        (
            "",
            NOSORT,
            50,
        ),
        (_("Type"), 1, 100),
        (_("Description"), 2, 150),
        (_("Date"), 4, 100),
        ("", NOSORT, 50),
        (_("Age"), 6, 100),
        ("", NOSORT, 50),
        (_("Place"), 7, 400),
        (_("Main Participants"), 8, 200),
        (_("Role"), 9, 100),
    ]

If you want more or less space for Description column increase or decrease the 150 entry.

To reorder or hide columns hack starting at line 128

    self.model.add(
        (
            event.get_handle(),
            str(event.get_type()),
            event.get_description(),
            event_date,
            event_sort,
            person_age,
            person_age_sort,
            place,
            participants,
            str(event_ref.get_role()),
        )
    )

I do not care to see the Participants column so comment the line out.

#participants,

Move lines around to change the order. Keep event_date and event_sort together. the same for the age column.

1 Like

That’s the problem. If you’re a Gramps user with no programming knowledge, hacking is not an option. And if you know how to hack, you have to redo it every time you install a new version.

The nice thing about hacks is that if you share it, there is a well-trod path to popular hacks being added to the core.

That is the lesson that I took from @GeorgeWilmes sharing of his enhance citation gramplet. @SNoiraud recognized the value and had the knowledge and skill to extend the added columns into all the Source Citation tabs of all object editors.

Likewise, @kku shared his Filter+ enhanced gramplet and the added value (scraping to create a custom filter and a stopwatch timer) was so obvious. He was coaxed into submitting the enhancements and they were folded into the Gramps 6.0 core.

(A side-effect in the Filter+ example is quite unfortunate. Folding Kari’s experimental gramplet into the core effectively neutured the testbed. When it was still an add-on, he would readily tweak it to add a minor improvement and publish that through the Addon Manager. Now, unless there is another huge innovation, he feels there isn’t enough value to have a separate set of addons. So innovation is stifled.)