View Full Version : Error importing NSOutlineViewDataSource in PyObjC code

Feb 28, 2009, 03:40 PM
Hi everyone, first post. :-)

I'm having a problem importing NSOutlineViewDataSource in a Python Cocoa application. The problem is easily reproduced by creating a new Python Cocoa application (document based), and adding the following to main.py just before AppHelper.runEventLoop():

from AppKit import NSOutlineViewDataSource

The error I get is:

Traceback (most recent call last):
File "/Users/colin/Desktop/Untitled/build/Debug/Untitled.app/Contents/Resources/main.py", line 19, in <module>
from AppKit import NSOutlineViewDataSource
ImportError: cannot import name NSOutlineViewDataSource

Anyone know what the deal is? Thanks.

Feb 28, 2009, 03:48 PM
Forgot to mention, my machine is running 10.5.6 and, as far as I know, everything is up to date.

MacRumors Guy
Feb 28, 2009, 07:22 PM
You can't import it and you don't need to import it.

Feb 28, 2009, 09:56 PM
Care to be more specific?

Mar 1, 2009, 04:20 AM
NSOutlineViewDataSource is a protocol, not a class. See:


Short version, you don't need to do anything special to support informal protocols. Just make sure your Python class (which should be a descendent of NSObject) supports the methods described by the protocol.

More information on ObjC protocols if you need it:


Mar 1, 2009, 05:36 PM
Thanks, hhas.