PyObjC Framework ColorSync

12.1 · active · verified Tue Apr 14

pyobjc-framework-colorsync provides Python wrappers for Apple's ColorSync framework on macOS. It allows Python applications to interact with macOS's color management system, including accessing color profiles and performing color conversions. As part of the larger PyObjC project, it closely follows macOS SDK updates and typically releases alongside new macOS versions and major Python releases, maintaining compatibility with the latest macOS features.

Warnings

Install

Imports

Quickstart

This example demonstrates how to import the ColorSync framework and use a common C-level function, `ColorSyncGetDefaultProfileID`, to retrieve the default color profile identifier for the primary display. This illustrates basic interaction with the framework's C APIs.

import ColorSync
import objc # Recommended for general PyObjC interaction as it sets up the bridge

# ColorSync interactions often involve C functions or Core Foundation types.
# Get the default profile ID for the primary display.
# The domain argument expects a byte string (e.g., b"display", b"output").
# The function returns a CFStringRef, which PyObjC automatically bridges to a Python string.
try:
    display_profile_id = ColorSync.ColorSyncGetDefaultProfileID(b"display")
    print(f"Successfully retrieved default display profile ID: {display_profile_id}")
except AttributeError:
    print("Error: ColorSyncGetDefaultProfileID not found. Ensure the ColorSync framework is available and PyObjC is correctly installed on macOS.")
except Exception as e:
    print(f"An unexpected error occurred while accessing ColorSync: {e}")

# This quickstart demonstrates importing the framework and calling a basic C-level function,
# which is a common pattern for interacting with some parts of PyObjC-wrapped frameworks.

view raw JSON →