Recently, I’ve been busy exploring 2d graphics algorithms for generating great looking logos, wallpapers, and backgrounds. The article “Blog Redesign” drew my attention to a great tool on Mac OS X. NodeBox is an open-source application for programming 2-dimensional graphics and animation in the Python language. NodeBox lets the user focus on coding graphics without worrying about the underlying technology.
It is based on another open-source project, DrawBot, and is inspired by technologies like OpenGL and PostScript. This means NodeBox is based on vector graphics rather than pixels. As such it’s an excellent tool for generating 2D graphics intended for print, and in particular typographic experiments. NodeBox can generate PDF documents that can easily be used in Adobe Illustrator or any professional vector graphics package. NodeBox can also generate QuickTime movies for animations.
If you’re curious, the NodeBox Gallery shows off some good-looking sketches. Tom de Smedt, one of NodeBox’s authors, has published two good examples: Supercurly uses the modular font Superveloz by Andreu Balius to construct organic compositions, while Photobjects is a database of images which can be queried for images connected to certain keywords. These are then used to create randomized collages of images.
Prism is an algorithm for creating a color palette on any subject. It uses the internet as a semantic database.
NodeBox is available in version 1.0 release candidate 7, and is sophisticated enough to count as a real production tool. However, NodeBox is compiled only as a PowerPC binary for Mac OS X. As a proud owner of a new Intel-based Macbook, I’ve been looking for a way to compile the source (included in the download) as a binary for Intel-based Macs.
So read on for the required steps to compile and build it yourself, or just download my build, NodeBox 1.0rc7 Intel Binary for Mac OS 10.4.
1. Installation of required Tools and Libraries
The first part requires the installation of some essential tools that are missing from Mac OS X 10.4’s bundled Python 2.3.5. The tools are:
- PyObjC 1.4 for Python 2.3, Mac OS X 10.4, the Python-Cocoa bridge.
- Numeric, a Python library for numerical calculations.
- Py2App, a solution for packaging Python applications as regular Mac OS X application bundles (programs).
I thought that the installation would be a no-brainer. But it turned out there were some issues the took me some hours to fix. Here’s my step-by-step guide of what I’ve done:
Install the Apple Developer CD
We require the GNU compiler and tools (XCode and the Apple Documentation is not required).
Download the PyObjC 1.4 source release (a compressed tar archive).
Extract it and open a terminal. Enter
python setup.py bdist_mpkg --open
This will compile and build an Mac OS X installation package and open it. Now, this is important: DO NOT INSTALL py2app; you should select “Custom Installation” and deselect all py2app 0.2.5 items!
Download the Numeric source package.
In the terminal enter
sudo python setup.py install
An admin account is required for the sudo!
Download the py2app 0.3.4 source package for Mac OS X 10.4 and Python 2.3.
Py2App seems to be broken and would produce a binary that prints an error message upon startup:
An unexpected error has occurred during execution of the main script
‘/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/lib-dynload/objc/_objc.so’ not found
Very annoying! But there’s an easy fix: we have to modify a file to make it work and produce a proper NodeBox binary:
In folder “py2app/apptemplate” of the source package, open the source file “plist_template.py” and locate the line (line 26)
and replace it with
PyResourcePackages=[(s % version) for s in [
Now build and install Py2App with
sudo python setup.py install
Again, an admin account is required for the sudo!
2. Patching and Building NodeBox
The source of NodeBox requires some fixes to work under 10.4 and Python 2.3.
First download the NodeBox DMG file from the homepage and extract the Source folder.
Edit QTSupport.py and locate the line (line 8 )
import QuickTime as Qt
and replace it with
import QTKit as Qt
Copying Missing Files
The Dashboard.py file is missing in the source. So take the PowerPC-Binary and copy the file Dashboard.pyc over to the Source folder. The file is located in the ZIP archive “site-packages.zip” in the folder “NodeBox.app/Contents/Resources/Python”. Just copy it into the “Source” folder. You might use a tool like BetterZIP.
Finally, build the NodeBox application with
python setup.py py2app
The application is located in the dist folder.
Copy Missing Help Files
They are also missing in the Source folder. So copy them over, like
ditto "../PPC/NodeBox.app/Contents/Resources/English.lproj/NodeBox Help" "dist/NodeBox.app/Contents/Resources/English.lproj/NodeBox Help"
Copy the NodeBox.app to your program folder.
That’s it. Enjoy!
If you forgot to patch Py2App and get the error message shown above, then try to modify the Info.plist of the built NodeBox application bundle. Replace