PyObjC EventKit Framework

12.1 · active · verified Tue Apr 14

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

Install

Imports

Quickstart

This quickstart initializes an `EKEventStore` and attempts to list the user's available calendars for events. This operation requires user permission for 'Calendar' access on macOS, which will be prompted the first time your application requests access. Ensure your application is properly sandboxed and entitled if distributing, or grant permissions manually during development.

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.")

view raw JSON →