{"id":6165,"library":"pyobjc-framework-screensaver","title":"PyObjC Framework ScreenSaver","description":"PyObjC Framework ScreenSaver provides Python bindings and wrappers for the macOS ScreenSaver.framework, enabling Python developers to interact with and create macOS screensavers. It is part of the larger PyObjC project, which offers comprehensive bridges to Objective-C frameworks. The current version is 12.1 and its release cadence is tied to updates in the macOS SDK and Python version support by the core PyObjC project.","status":"active","version":"12.1","language":"en","source_language":"en","source_url":"https://github.com/ronaldoussoren/pyobjc","tags":["macos","screensaver","pyobjc","frameworks","gui"],"install":[{"cmd":"pip install pyobjc-framework-screensaver","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"This package is a framework binding and requires the core PyObjC bridge.","package":"pyobjc-core","optional":false},{"reason":"Requires Python 3.10 or newer.","package":"python","optional":false}],"imports":[{"note":"PyObjC framework bindings are typically imported directly by their framework name (e.g., 'ScreenSaver'), not from their PyPI package name.","wrong":"from pyobjc_framework_screensaver import ScreenSaver","symbol":"ScreenSaver","correct":"import ScreenSaver"}],"quickstart":{"code":"import ScreenSaver\nimport objc\nfrom Foundation import NSMakeRect, NSObject # Needed for basic Cocoa types\n\n# Get a reference to the SSScreenSaverView class\nSSScreenSaverView = ScreenSaver.SSScreenSaverView\n\nprint(f\"Successfully imported ScreenSaver.SSScreenSaverView: {SSScreenSaverView}\")\nprint(f\"Is SSScreenSaverView an Objective-C class? {objc.is_objc_class(SSScreenSaverView)}\")\n\n# To demonstrate basic instantiation (requires Cocoa types like NSRect)\n# Note: A functional screensaver requires proper macOS application context.\ntry:\n    dummy_frame = NSMakeRect(0, 0, 100, 100)\n    # Instantiate an SSScreenSaverView; this will create the Objective-C object.\n    # It won't be visible or functional without being added to a view hierarchy.\n    saver_view = SSScreenSaverView.alloc().initWithFrame_isPreview_(dummy_frame, False)\n    print(f\"Created a dummy SSScreenSaverView instance: {saver_view}\")\n    # In a real screensaver, you would subclass SSScreenSaverView and override\n    # methods like 'drawRect_' or 'animateOneFrame'.\nexcept Exception as e:\n    print(f\"Could not fully instantiate SSScreenSaverView in this context: {e}\")\n","lang":"python","description":"This quickstart demonstrates how to import the ScreenSaver framework and access a core class like `SSScreenSaverView`. While it shows basic instantiation, developing a functional screensaver requires subclassing `SSScreenSaverView` and integrating within a proper macOS screensaver project structure."},"warnings":[{"fix":"Ensure your Python environment is 3.10 or newer to use the latest versions of PyObjC and its framework bindings.","message":"PyObjC 12.x (and thus `pyobjc-framework-screensaver` 12.x) dropped support for Python 3.9. Earlier PyObjC versions (11.x) dropped support for Python 3.8.","severity":"breaking","affected_versions":"pyobjc-framework-screensaver 12.0+"},{"fix":"If custom initialization is needed for Objective-C instances, either implement your own `__new__` method or define Objective-C style initializer methods (e.g., `initWithName_`) and expose them via PyObjC.","message":"When subclassing Objective-C classes in Python, if your class relies on PyObjC's default `__new__` method for Objective-C object creation, you cannot define a traditional Python `__init__` method. Initialization logic should typically be handled within `__new__` or an Objective-C style initializer method.","severity":"gotcha","affected_versions":"pyobjc-framework-screensaver 10.3+"},{"fix":"Review any custom `__init__` or initializer methods that interact directly with Objective-C objects (e.g., via `alloc`) to ensure they adhere to standard ARC memory management rules for initializer methods.","message":"PyObjC 11.1 introduced changes to align the core bridge's Automatic Reference Counting (ARC) behavior with `clang`'s documentation, specifically for 'init' family methods. These methods now correctly steal a reference to `self` and return a new one, which might affect existing custom `__init__` implementations or complex initialization patterns that rely on previous PyObjC reference counting behavior.","severity":"gotcha","affected_versions":"pyobjc-framework-screensaver 11.1+"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z","problems":[]}