Files changed (12)
+13 -36pyobjc/Examples/WebServicesTool/Web Services Tool.pbproj/project.pbxproj
Of course, if you localize the python scripts, they won't be automatically found. However, this would be easy to fix by calling NSBundle's -preferredLocalizations method and adding the associated localization directories to sys.path.
-To create a new PyCocoa project in Project Builder, do the following. Of course, this assumes that pyobjc is correctly installed. This has been tested with python built via Fink -- it should work fine with any build of python. Unfortunately, it will not work with the Python shipped with OS X as that distribution is incomplete -- it lacks a library to link against (either dynamic or static).
+To create a new PyCocoa project in Project Builder, do the following. Of course, this assumes that pyobjc is correctly installed. This has been tested both with the Fink build of Python and with the Apple supplied version of Python.
-2. Add libpython2.2.a to project (or Python.framework, if using the framework build). For a standard Fink installation, the library will be in /sw/lib/python2.2/config/.
-3. If not using the framework build, add the python include path to the project's search path (/sw/include/python2.2/ for Fink).
+3. Add the key 'PrincipalPythonFile' to the Info.plist. The value is the name of the Python file that you want to be loaded first as the application starts up. Whatever Python file is chosen, it should take care of loading any other Python files necessary to define the various classes necessary for application startup. If this key is not defined, the main() function will try to load the file 'Main.py'. If that file is not found, the application will raise an exception and exit.
+If you want to create a project that will create a standalone Cocoa application that contains all the resources necessary to run the application, perform the following additional steps:
-5. Add the key 'PrincipalPythonFile' to the Info.plist. The value is the name of the Python file that you want to be loaded first as the application starts up. Whatever Python file is chosen, it should take care of loading any other Python files necessary to define the various classes necessary for application startup. If this key is not defined, the main() function will try to load the file 'Main.py'. If that file is not found, the application will raise an exception and exit.
-6. Add '-undefined suppress -force_flat_namespace' to the linker flags for the project. You can also turn off the prebinding feature as it doesn't work anyway.
-NOTE: See the Web Services Tool example as it implements an application that is intended to actually do something useful (beyond the very useful task of testing the PyObjC module). Also -- step 5 should likely be skipped. Instead, add a Main.py file to your project that imports all of the python files that define classes necessary for App startup -- see the Web Services Example...
+6. Drag in the AppKit, Foundation, and objc directories from /sw/lib/python2.2/site-packages/ and create absolute path references (you can copy the folders into the project, but it isn't a requirement unless there will be developers contributing to the project that do not have pyobjc installed).
+9. Set the Copy Files phase to copy the three files into a subdirectory named 'pyobjc' [optional, but keeps the Resources directory more organized].
+If you want to mix in compiled Objective-C classes, add a bundle or framework target to your project. Then, in the Main.py (or equivalent), load the framework or bundle using the NSBundle API as normal. Because the main class passes control entirely to the python command-line executable, classes linked into the binary in the traditional fashion (by simply adding the source files to the project) will not be available at runtime.
- tableView_objectValueForTableColumn_row_ = selector(tableView_objectValueForTableColumn_row_, signature='@@:@@i')
+ tableView_objectValueForTableColumn_row_ = objc.selector(tableView_objectValueForTableColumn_row_, signature='@@:@@i')
+ This main file uses execve() to transfer control of execution to the standard command line python interpreter. As such, compiled classes in the project will not actually be linked into the runtime as execve() effectively overlays the existing process with the process being called -- in this case the python command line tool.
+ To use compiled classes with this main, create a separate bundle target and load the bundle in the Main.py file.
- NSString *mainPyFile = [[[NSBundle mainBundle] infoDictionary] objectForKey: @"PrincipalPythonFile"];
+ NSString *mainPyFile = [[[NSBundle mainBundle] infoDictionary] objectForKey: @"PrincipalPythonFile"];
- NSLog(@"*** WARNING *** PrincipalPythonFile key either did not exist in Info.plist or the file it referred to did not exist. Trying 'Main.py'.");
- format: @"%s:%d pyobjc_main() Failed to find main python entry point for application. Exiting.", __FILE__, __LINE__];
+ format: @"%s:%d pyobjc_main() Failed to find main python entry point for application. Exiting.", __FILE__, __LINE__];
- format: @"%s:%d pyobjc_main() Failed to run the python file at '%@'.", __FILE__, __LINE__, mainPyPath];
Web Services Tool queries XML-RPC enabled servers via the "standard" introspection methods and displays a summary of the API. It is implemented in Python using the PyObjC module.
+To use the application, simply provide the connection window with an URL to the XML-RPC handler of a web server. If the server at least implements the listMethods() method, the app will display a list of methods.
pyobjc/Examples/WebServicesTool/Web Services Tool.pbproj/project.pbxproj
+#error The project does not use this file. It is left here both for reference purposes (if anyone is interested in going the embedded interpreter route) and in case Apple ships the Python library in OS X (the embedded interpreter is actually more efficient).
This main file can be used in cases where the developer desires to embed the python interpreter directly into the application. The pyobjc_main() function initializes the python interpreter in an embedded context.
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.