pyobjc-framework-pencilkit provides Python wrappers for Apple's PencilKit framework on macOS. It is part of the PyObjC project, a bidirectional bridge enabling Python scripts to interact with Objective-C libraries, including macOS Cocoa frameworks. The current version is 12.1 and it maintains an active release cadence, typically aligning with macOS SDK updates and Python version support.
pip install pyobjc-framework-pencilkitVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a basic macOS application using PyObjC that displays a `PKCanvasView` and a `PKToolPicker` for drawing. It sets up a standard Cocoa application window and integrates PencilKit components, allowing for user interaction with an Apple Pencil or trackpad/mouse.
Upgrade your Python environment to Python 3.10 or later for PyObjC 12.x (including this package). Always check `requires_python` on PyPI or the PyObjC changelog for specific version requirements.
Review code that interacts with object initialization, especially custom subclasses or factory methods, to ensure correct reference handling. Explicit memory management is rarely needed in Python, but understanding the underlying Objective-C semantics is crucial for correct behavior.
Only use `pyobjc-framework-pencilkit` in macOS environments. For cross-platform drawing or GUI development, consider alternative libraries.
Always check for `None` before calling methods on PyObjC-wrapped objects that might originate from Objective-C `nil` values. E.g., `if my_obj is not None: my_obj.doSomething_()`.
Ensure custom classes requiring KVO inherit from `AppKit.NSObject` or `Foundation.NSObject`. Use `Foundation.NSMutableArray` and `Foundation.NSMutableDictionary` for collections that will be observed.