PyObjC Collaboration Framework

12.1 · active · verified Tue Apr 14

PyObjC-framework-collaboration provides Python wrappers for Apple's Collaboration framework on macOS, enabling Python scripts to access identity and user selection features. It is part of the broader PyObjC project, a bridge between Python and Objective-C. The current version is 12.1, and it maintains an active release cadence, typically aligning with macOS SDK updates and Python version support.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import the `Collaboration` framework and list the available identity authorities on a macOS system. For interactive operations like presenting an identity picker, an `AppKit` run loop would typically need to be active. The example includes a minimal `NSApplication` setup for broader compatibility with PyObjC patterns, though it might not be strictly necessary for simple authority listing.

import objc
from Collaboration import CBIdentityAuthority
from AppKit import NSApplication, NSApp # Required for an active run loop in UI applications

def list_identity_authorities():
    """Lists available identity authorities on the system."""
    authorities = CBIdentityAuthority.allAuthorities()
    if authorities:
        print("Available Collaboration Identity Authorities:")
        for authority in authorities:
            print(f"- {authority.displayName()} (Type: {authority.type()})")
            if authority.isLocal():
                print("  (Local Authority)")
            print(f"  Identifier: {authority.identifier()}")
    else:
        print("No Collaboration Identity Authorities found.")

if __name__ == "__main__":
    # For non-UI interactions, a run loop is not strictly necessary but
    # for many PyObjC applications, especially those involving UI,
    # NSApplication.sharedApplication() or an active run loop is needed.
    # Starting a minimal AppKit environment for consistency.
    if not NSApp:
        NSApplication.sharedApplication()

    list_identity_authorities()

view raw JSON →