PyObjC ClassKit Framework

12.1 · active · verified Tue Apr 14

PyObjC-framework-ClassKit provides Python wrappers for the ClassKit framework on macOS, enabling Python applications to interact with educational data like assignments, activities, and progress. It is part of the broader PyObjC project, currently at version 12.1, and typically releases updates in sync with macOS SDK changes.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import the ClassKit framework and access the current ClassKit context. Note that ClassKit operations require an active macOS application context, appropriate entitlements, and user authorization to function correctly. This code is illustrative and would typically run within a larger PyObjC-based macOS application.

import ClassKit
from Cocoa import NSObject, NSLog # For basic logging or NSObject base

# ClassKit operations must typically be run on the main thread and
# within a macOS application context. This is a conceptual example.
# In a real app, you would interact with CLSDataStore and CLSContext.

# Get the current ClassKit context (requires user authorization and an active app)
current_context = ClassKit.CLSContext.currentContext()

if current_context:
    NSLog(f"ClassKit context loaded: {current_context.title()}")
    # Example: Create a new activity for the current context
    # This part requires proper setup of CLSActivity, CLSActivityItem etc.
    # and permissions. This is a simplified example.
    # activity = ClassKit.CLSActivity()
    # activity.setTitle_("My Python Activity")
    # current_context.addActivity_(activity)
    # ClassKit.CLSDataStore.shared().saveWithCompletion_(
    #     lambda success, error: NSLog(f"Activity save success: {success}, error: {error}")
    # )
else:
    NSLog("ClassKit context not available. Ensure app is authorized and running on macOS.")

# In a real macOS app, you might also have a PyObjC application loop running.

view raw JSON →