PyObjC ScreenTime Framework

12.1 · active · verified Tue Apr 14

PyObjC is a bridge between Python and Objective-C, enabling Python scripts to use and extend existing Objective-C class libraries, primarily Apple's Cocoa frameworks. `pyobjc-framework-screentime` provides Python wrappers for the macOS ScreenTime framework, allowing access to its APIs. The library is currently at version 12.1 and maintains an active release cadence, typically aligning with macOS and Python version updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates basic object instantiation and method calling using `Foundation.NSDate`, a common pattern applicable across PyObjC frameworks. Specific ScreenTime API usage will follow Apple's Objective-C documentation.

import Foundation
import ScreenTime # Import the specific framework

def demonstrate_pyobjc_basics():
    """Demonstrates basic PyObjC object creation and method calls."""
    # Example using a common Foundation class
    now = Foundation.NSDate.date() # Pythonic instantiation (available since PyObjC 10.3)
    print(f"Current NSDate object: {now}")
    print(f"Description of NSDate: {now.description()}")

    # To use ScreenTime, you would typically interact with its specific classes and functions.
    # For instance, if ScreenTime had a class like 'STConfiguration' (hypothetical example):
    # try:
    #     config_manager = ScreenTime.STConfiguration.alloc().init()
    #     print(f"ScreenTime configuration manager: {config_manager}")
    # except AttributeError:
    #     print("Hypothetical STConfiguration class not found or API not accessible.")

    print("Note: Actual ScreenTime API usage requires specific macOS versions, permissions, and understanding of Apple's documentation.")

if __name__ == "__main__":
    demonstrate_pyobjc_basics()

view raw JSON →