Building GUIs for Apple OS X traditionally meant you would code in Objective C. To overcome this issue people have made programming bridges to allow development in other languages. PyObjC is the project that enables Python programmers to take advantage of Cocoa, Apple's development environment. I recently began learning how to use PyObjC, and how to make (almost) pure Python GUI applications.

PyObjC isn't new, it has been around for a while, and there is actually a pretty good tutorial for wiring an interface up with Python. Leopard (10.5) ships with Python 2.5 and PyObjC 2.0, meaning there is nothing we need to install. Additionally Apple has also shipped support for Python in Xcode. This makes certain things much easier.

The current tutorial directs a user to build an interface, and then take the generated Nib file* and run a script that generates the appropriate controller. From here the user can create a fully working app bundle without needing Objective C. There are a few annoying things:

Xcode 3.0, which ships with Leopard, provides support for Python, allowing the controller to be developed completely in the language. Interface Builder knows how to understand Python files, so you can attach actions and variables directly, with only a few necessary tricks.

In this series I will go through the steps to build a simple, but useful, application. There will be no Objective C written, only Python.

* Xcode 3.0 defaults to version 3 Nib files, which will not work with the PyObjC tutorial. You'll have to Save As a version 2 Nib file.

Part 2: Starting A Cocoa-Python Application >>

Posted: Jun 11, 2008 | Tags: python osx programming pyobjc cocoa

Comments are closed.


42 | django | python | oggify | OSCON | OSCON07 | osx | utosc | mythtv | security | reading | music | gaming | programming | tips | shell | vim | pyobjc | cocoa | iphone | blog | git


<< Jun >>
Mo Tu We Th Fr Sa Su
26 27 28 29 30 31 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 1 2 3 4 5 6


This space reserved for a search box

A Django site. Hosted on a Slicehost Slice