[Pythonmac-SIG] NewBie question: Building GUI for Mac

Kevin Walzer kw at codebykevin.com
Fri Jun 6 16:33:08 CEST 2008


Abhiram Dwivedi wrote:
> Hello,
> 
> I want to know if its possible to build a standalone GUI app for Mac using python. I need to build some application and still going through pythong tutorials. It seems Cocoa is the only option, but I want to be sure before moving away from python.
> 
> I need to integrate it with RSS and growl notifications as well.
> 
> Thanks in advance.

Ah, welcome to the wonderful world of Python GUI toolkits! So many to 
choose from...

You can use PyObjC, wxPython, PyQt, and Tkinter--these are the major 
"native" GUI toolkits on Mac. Gtk/PyGtk is still an X11 application 
mainly (there's a port to running natively on OSX in progress, but it's 
not stable yet).

A few quick notes:

1. PyObjC is, as you say, the "most-Mac" approach. It allows full access 
to the Cocoa frameworks. The main drawback to using PyObjC is that it is 
pretty much a thin wrapper over Objective-C, and so you really need to 
understand Objective-C to learn the Cocoa frameworks. There have been a 
lot of changes between PyObjC 2.0 and older versions, and a lot of the 
documentation is either out-of-date or nonexistent. The best approach to 
learning PyObjC these days seems to be to buy a good Cocoa textbook and 
translate the examples to Python. (Aaron Hillegass's book is highly 
recommended and has just been updated--see 
http://www.amazon.com/exec/obidos/ASIN/0321503619/bignerdranch-20.)

2. wxPython is cross-platform but looks great on the Mac with some 
attention to UI design, is well-documented (both in terms of available 
sample code online and books), and has a supportive community. It 
doesn't provide many Mac-specific hooks like PyObjC does, but it's quite 
sufficient for a nice application. One possible drawback to wxPython is 
that it runs on top of the Carbon frameworks, which are now deprecated 
on the Mac and will probably go away in the next several years. The plan 
to port wxPython to use Cocoa is somewhat hazy at this 
moment--wxWidget's Mac maintainer says he is implementing things gradually.

3. PyQt is also cross-platform, and also looks good on the Mac with some 
attention to UI design--it might take a bit more effort here. It also 
has a supportive community, and good documentation--lots of online code 
samples and a new book can help you get going. Like wxPython, it doesn't 
provide many Mac-specific hooks. PyQt currently runs on Carbon, but the 
underlying toolkit (Qt) is actively being ported to Cocoa by its 
developers, Trolltech, so it is heading in Apple's recommended direction.

4. Tkinter comes with Python, and is easier to learn than the other 
toolkits. Basic Tkinter is well-documented and has a supportive 
community around it. The drawback is that it is a more spartan toolkit 
out of the box, and you have to work with a lot of extension packages to 
get a more sophisticated GUI. I use Tkinter as my toolkit and have not 
found a compelling reason to switch, but I've also done a lot of work on 
assembling a set of libraries that give the UI of my Python program the 
polish that Mac users demand. Like wxPython and PyQt, Tkinter doesn't 
offer a lot of Mac-specific hooks, and it also runs on Carbon. The plan 
to port Tkinter to Cocoa is also somewhat hazy at this point; a 
developer says he's working on it, but no releases or even much public 
discussion of his progress have been posted.


As far as the other components of your app, the available Python 
libraries for RSS would work (the best one is Mark Pilgrim's Universal 
Feed Parser, see http://feedparser.org/). Growl has Python bindings, and 
can also be called from the command-line via AppleScript.

Hope this helps,
Kevin

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com


More information about the Pythonmac-SIG mailing list