PyObjC CalendarStore Framework
PyObjC-framework-CalendarStore provides Python wrappers for the macOS CalendarStore framework (deprecated since macOS 10.8). It enables Python scripts to access, modify, and receive notifications for iCal data, including calendars, events, and tasks. The library releases new versions regularly, typically aligning with macOS SDK updates and Python version support, with version 12.1 being the current stable release.
Warnings
- deprecated The underlying macOS CalendarStore framework has been deprecated by Apple since macOS 10.8. For new development, Apple recommends using the EventKit framework. While pyobjc-framework-calendarstore is still maintained, its functionality is built upon an outdated macOS API.
- breaking PyObjC 12.0 and later dropped support for Python 3.9. PyObjC 11.0 dropped support for Python 3.8. Ensure your Python environment meets the minimum requirements for the PyObjC version you are using.
- gotcha In PyObjC 10.3, a change prevented user-defined `__init__` methods in Python subclasses of Objective-C classes from being called if a custom `__new__` method was not also explicitly implemented. This was partially reverted in 10.3.1 to allow `__init__` to work when `__new__` is present.
- breaking PyObjC 11.1 aligned its behavior for initializer methods (those starting with 'init' in Objective-C) with `clang`'s Automatic Reference Counting (ARC) documentation. These methods now correctly 'steal' a reference to `self` and return a new reference. This might break code that relied on the previous PyObjC proxy behavior for `[NSObject alloc]` and its subsequent `init` method.
- gotcha PyObjC 11.0 introduced experimental support for free-threading (PEP 703) in Python 3.13. This involved significant internal changes to the core bridge. While aimed at performance improvements, experimental features can have unexpected behavior or require careful consideration for thread safety.
Install
-
pip install pyobjc-framework-calendarstore
Imports
- CalCalendarStore
from CalendarStore import CalCalendarStore
- CalEvent
from CalendarStore import CalEvent
- CalTask
from CalendarStore import CalTask
Quickstart
import objc
from CalendarStore import CalCalendarStore
from Cocoa import NSDate, NSLog # Required for NSDate, commonly used with CalendarStore
# Get the default calendar store
store = CalCalendarStore.defaultCalendarStore()
if store:
NSLog("Successfully connected to CalendarStore.")
# List all calendars
calendars = store.calendars()
if calendars:
NSLog(f"Found {len(calendars)} calendars:")
for calendar in calendars:
NSLog(f" Name: {calendar.title()}, Type: {calendar.type()}")
else:
NSLog("No calendars found.")
else:
NSLog("Failed to get default CalendarStore.")