PyObjC EventKit Framework
PyObjC provides Pythonic wrappers for macOS Cocoa frameworks, allowing Python applications to interact directly with native macOS APIs. The `pyobjc-framework-eventkit` package offers bindings specifically for Apple's EventKit framework, enabling Python developers to work with calendar events, reminders, and calendars on macOS. The current version is 12.1, and releases are tied closely to macOS SDK updates and Python version support, typically with multiple releases per year.
Warnings
- breaking PyObjC 12.0 dropped support for Python 3.9. If you are using Python 3.9, you must upgrade your Python version to 3.10 or later to use PyObjC 12.x.
- breaking PyObjC 11.0 dropped support for Python 3.8. Users on Python 3.8 must upgrade their Python version to 3.9 or later (and 3.10+ for PyObjC 12.x).
- breaking PyObjC 11.1 aligned its behavior for `init` family methods with clang's Automatic Reference Counting (ARC) documentation. This might change reference counting behavior for custom initializer methods defined in Python subclasses of Objective-C objects, potentially leading to memory management issues if not accounted for.
- gotcha PyObjC is a macOS-specific library. It provides bindings to Apple's Cocoa frameworks and will only run on macOS. It is not compatible with other operating systems like Linux or Windows.
- gotcha Access to EventKit data (calendars, events, reminders) requires explicit user permission on macOS. Your application must be properly signed and have the correct entitlements (e.g., `com.apple.security.personal-information.calendars`), and the user will be prompted on first access. Without permission, EventKit API calls will fail.
- breaking The `IMServicePlugIn` framework bindings were removed in PyObjC 10.0. This aligns with Apple's deprecation and subsequent removal of the framework in macOS 14.
Install
-
pip install pyobjc-framework-eventkit
Imports
- EKEventStore
from EventKit import EKEventStore
- EKEvent
from EventKit import EKEvent
- EKCalendar
from EventKit import EKCalendar
- EKEntityTypeEvent
from EventKit import EKEntityTypeEvent
Quickstart
import objc
from EventKit import EKEventStore, EKEntityTypeEvent
# Initialize Event Store
store = EKEventStore.alloc().init()
# Note: Access to EventKit data requires user permission on macOS.
# Your application must be signed and have the correct entitlements.
# The user will be prompted for permission on first access. Once granted,
# subsequent runs will not prompt again.
# Attempt to fetch calendars for events (EKEntityTypeEvent)
# In a real application, you would first check authorizationStatusForEntityType_
# and requestAccessToEntityType_completion_ if needed.
print("Attempting to fetch calendars (requires Calendar access permission)...")
try:
calendars = store.calendarsForEntityType_(EKEntityTypeEvent)
if calendars:
print(f"Found {len(calendars)} calendars:")
for calendar in calendars:
print(f" - Title: {calendar.title()}, Type: {calendar.type()}")
else:
print("No calendars found for events.")
except Exception as e:
print(f"Error fetching calendars: {e}")
print("Make sure your application has Calendar access permission in System Settings > Privacy & Security.")
print("Quickstart complete.")