Author: | Bill Bumgarner |
---|---|
Contact: | bbum@codefab.com |
To use the project templates, simply copy (or link) them into the Project Templates directory used by Project Builder. The project templates are also included in the PyObjC installer package.
loadBundle()
function in the objc
module:objc.loadBundle("MyFramework", globals(), bundle_path="/path/to/MyFramework.framework")
This has the effect of importing all of the classes in the bundle or framework into the current python scope's globals. For all intents and purposes, it is similar to:
from Foundation import *
- The Project Templates directory includes a clean.py script that removes noise files from the project templates. When working on project templates, it is recommended that this script be invoked before creating a test project from one of the templates. For example, the presence of user specific project builder settings will cause any projects created from a template to be incorrect.
The Cocoa-Python templates all create various different kinds of Cocoa application projects. Some of the resulting projects are incompatible with Apple's build of Python[#]. Be sure and pick the correct project type for your needs.
A project created from this template is designed to implement standalone, pure-Python, applications that are compatible with Apple's build of Python as well as all other builds of python that support PyObjC.
When building the 'install' target, the resulting application wrapper will included the PyObjC module and can be launched on any stock OS X 10.2 system without requiring PyObjC to be preinstalled.
A project created from this template includes an embedded framework project into which all compiled code can be placed. Upon launch, the application automatically dynamically loads the embedded framework containing the compiled code.
Each Framework's Resources directory is automatically added to sys.path.
This template works like the Cocoa-Python Application template in that it is compatible with the Apple build of Python. It creates an application that uses Cocoa's Multiple Document Architecture in the same fashion as the default Cocoa Document-based Application supplied with Project Builder.
A project created from this template includes an embedded framework project into which all compiled code can be placed. Upon launch, the application automatically dynamically loads the embedded framework containing the compiled code. It is based on the Cocoa-Python Document-based Application template. It creates an application that uses Cocoa's Multiple Document Architecture in the same fashion as the default Cocoa Document-based Application supplied with Project Builder.
Each Framework's Resources directory is automatically added to sys.path.
[1] | Apple's build of python lacks a shared or static library to which an
application can be linked. As such, it is impossible to embed the
Python interpreter into an application. Because of this, it is
impossible to directly link compiled objective-c directly into an
application project. Hence, the "Apple Python compatible" projects are
labeled as 100% pure Python. Since bundles and frameworks can be
loaded into such applications, it is still possible to use compiled
classes. |