PyObjC PhotosUI Framework

12.1 · active · verified Tue Apr 14

pyobjc-framework-photosui provides Python bindings for Apple's PhotosUI framework on macOS, allowing Python developers to interact with system-level Photos user interface components. It is part of the larger PyObjC project, which acts as a bridge between Python and Objective-C. The library is actively maintained, with version 12.1 being the latest stable release, and it generally releases new versions in conjunction with major macOS SDK updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import the `PhotosUI` framework and access a class within it. Most `PhotosUI` functionalities require a running Cocoa application, typically managed via `AppKit.NSApplication`. This snippet initializes the shared application (without starting its run loop) and attempts to access `PHLivePhotoView` to confirm the bindings are loaded. Full UI interactions would require more extensive setup.

import PhotosUI
import Foundation
import AppKit

# Most PhotosUI interactions require a running Cocoa application.
# This snippet demonstrates basic import and class access.
# For a functional UI example, a full PyObjC app setup with NSApplication is required.

def main():
    # Initialize a basic NSApplication (required for most Cocoa frameworks)
    app = AppKit.NSApplication.sharedApplication()
    
    # Access a PhotosUI class to confirm the framework is loaded
    try:
        # PHLivePhotoView is a common PhotosUI class introduced in iOS/macOS 10.11
        _ = PhotosUI.PHLivePhotoView
        print("Successfully imported PhotosUI and accessed PHLivePhotoView.")
    except AttributeError:
        print("Could not access PHLivePhotoView. Ensure macOS version supports PhotosUI and PyObjC is correctly installed.")
    
    # Note: A real PhotosUI application would involve delegates, windows, and an event loop.
    # app.run() # This would start the GUI event loop, blocking further execution.

if __name__ == '__main__':
    main()

view raw JSON →