Friday, October 11, 2002




Hint: Download the Web Services Tool application (see previous post).

Copy it to someplace convenient on your hard drive.

Ctrl-click on the and select "Show Package Contents".

Look in the "Resources" folder found in the "Contents" folder.

Open Main.py in your favorite editor.

Main.py bootstraps the application by loading the PyObjC module and the two python files that define the two classes for the application; the application delegate (subclass of NSObject) and the window controller (subclass of NSWindowController).

Everything about the app is 100% pure Cocoa. If you open MainMenu.nib in Interface Builder, that it contains an instance of the app delegate class. This class is completely defined within Python. Main.py simply ensures that it exists in the ObjC runtime by importing the file prior to calling NSApplicationMain().

There is nothing special about the application executable within that app. It simply calls execve() to pass control to /usr/bin/python. As such, that executable could be used as is to build other Cocoa/Python applications -- simply copy the app wrapper and edit the property list to reflect any name changes.

The you can also freely mix in compiled ObjC classes. You just need to stick them into a bundle or framework project such that they can be dynamically loaded.
5:39:14 PM    


Pure Python Standalone Cocoa App!

A couple of weeks ago I released a little Cocoa application that uses the "standard" XML-RPC introspection methods to display information about a server's RPC API.

Nothing special except that the application is implemented entirely in python against the Cocoa APIs using the PyObjC Python<->Objective-C bridge.

Today, Ronald Oussoren and I patched the PyObjC module such that it now works with the Python 2.2 build that ships with OS X 10.2. Subsequently, I modified the Web Services Tool application such that it can be executed as a standalone, double-clickable, totally standard, application without requiring any additional components be installed on the system.

That is, it is now possible to distribute full fledged Cocoa applications implemented entirely in Python that are of a reasonable size.

A prebuilt binary (on a disk image) can be had from here:

Download Web Services Tool
4:43:33 PM