Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar

# Event type plugins

Type | `betty.model.event_type.EventType`
Repository | `betty.model.event_type.EVENT_TYPE_REPOSITORY`

Event types are used to indicate the type of an Event, such as a birth, a death, or an marriage.

## Creating an event type

1. Create a new class that extends `betty.model.event_type.EventType` and implements the abstract methods, for example:

       from typing import override
       from betty.model.event_type import EventType

       class MyEventType(EventType):
         @override
         @classmethod
         def plugin_id(cls) -> str:
             return "my-module-my-event-type"

         # Implement remaining abstract methods...
         ...

2. Tell Betty about your event type by registering it as an entry point. Given the event type above in a module `my_package.my_module`, add the following to your Python package:

pyproject.toml

    [project.entry-points.'betty.event_type']
    'my-module-my-event-type' = 'my_package.my_module.MyEventType'

setup.py

    SETUP = {
        'entry_points': {
            'betty.event_type': [
                'my-module-my-event-type=my_package.my_module.MyEventType',
            ],
        },
    }
    if __name__ == '__main__':
        setup(**SETUP)

## See also

Read more about how to use event types and Betty’s built-in event types at Event Type.