Python-to-Objective-C bridge providing seamless interoperability between Python and Objective-C programming languages on macOS systems.
—
Decorators and descriptors for creating Interface Builder-compatible outlets, actions, and properties, enabling seamless integration with macOS app development workflows and Xcode's Interface Builder.
Descriptors for creating outlets that can be connected to Interface Builder elements.
def IBOutlet(name=None):
"""
Create an Interface Builder outlet descriptor.
Args:
name (str, optional): Name for the outlet (defaults to attribute name)
Returns:
Property descriptor that can be connected in Interface Builder
"""Decorator for marking methods as Interface Builder actions that can be connected to UI controls.
def IBAction(func):
"""
Mark method as an Interface Builder action.
Args:
func: Method to mark as IBAction
Returns:
Method that can be connected to UI controls in Interface Builder
"""Decorator for marking properties as inspectable in Interface Builder's attribute inspector.
def IBInspectable(prop):
"""
Mark property as Interface Builder inspectable.
Args:
prop: Property to mark as inspectable
Returns:
Property that appears in Interface Builder's attribute inspector
"""Class decorator for enabling design-time rendering in Interface Builder.
def IB_DESIGNABLE(cls):
"""
Mark class as Interface Builder designable for design-time rendering.
Args:
cls: Class to mark as designable
Returns:
Class that can render at design-time in Interface Builder
"""Usage Examples:
import objc
from objc import IBOutlet, IBAction, IBInspectable, IB_DESIGNABLE
@IB_DESIGNABLE
class MyViewController:
# Interface Builder outlets
titleLabel = IBOutlet()
submitButton = IBOutlet("submitBtn") # Custom name
# Inspectable properties (appear in Interface Builder)
@IBInspectable
@property
def cornerRadius(self):
return self._cornerRadius
@cornerRadius.setter
def cornerRadius(self, value):
self._cornerRadius = value
# Update UI based on property change
# Interface Builder actions
@IBAction
def submitButtonPressed_(self, sender):
"""Connected to button's Touch Up Inside event."""
print(f"Button pressed: {sender}")
self.handleSubmit()
@IBAction
def textFieldChanged_(self, sender):
"""Connected to text field's Editing Changed event."""
self.validateInput(sender.stringValue())
def handleSubmit(self):
"""Regular Python method (not an IBAction)."""
passThese decorators enable full integration with Xcode's Interface Builder:
This allows developers to use the visual interface design tools while implementing logic in Python, maintaining the standard macOS development workflow.
Install with Tessl CLI
npx tessl i tessl/pypi-pyobjc-core