PyObjC CompositorServices Framework

12.1 · active · verified Wed Apr 15

This library provides Python bindings for the macOS CompositorServices framework, enabling interaction with its Objective-C APIs. CompositorServices is a highly specialized framework used for building custom rendering pipelines for displays connected to Apple silicon. This specific binding is part of the larger PyObjC project, currently at version 12.1, which maintains a regular release cadence with updates corresponding to macOS SDK changes and Python version support.

Warnings

Install

Imports

Quickstart

Due to the highly specialized nature of the CompositorServices framework, a simple 'Hello World' directly using its APIs is not practical. This quickstart demonstrates basic PyObjC object creation and method calling using the general Foundation framework. To use CompositorServices, you would import its specific classes (e.g., `CSDisplayManager`) and interact with them according to Apple's CompositorServices documentation for macOS.

import objc
from Foundation import NSObject, NSBundle

# CompositorServices is a highly specialized framework.
# A simple 'Hello World' for it is not practical without
# deep knowledge of macOS graphics programming.
# This example demonstrates basic PyObjC class instantiation.

class MyPyObjCClass(NSObject):
    def init(self):
        self = super().init()
        if self is None:
            return None
        print("MyPyObjCClass instance initialized!")
        return self

    @objc.python_method
    def say_hello(self):
        print("Hello from PyObjC!")

if __name__ == "__main__":
    # Instantiate a basic PyObjC object
    obj = MyPyObjCClass.alloc().init()
    obj.say_hello()

    # For CompositorServices, you would import and use specific classes like:
    # from CompositorServices import CSDisplayManager
    # manager = CSDisplayManager.sharedManager()
    # ... and interact with its methods according to Apple's documentation.

view raw JSON →