It just needs a little bit of glue. You can't directly import a framework, but you can get objc to load the bundle.

Create a like this:

def _load(name, g):
    import objc
    objc.loadBundle(name, g, bundle_path='WiiRemote.framework')

_load(__name__,  globals())

and then you can

$ python
Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04)
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import WiiRemote
>>> w =
>>> w
<WiiRemote: 0x6ff830>

If WiiRemote.framework isn't in the current directory, your program will have to find it. The original template code from a Python app I'm working on had:

    from Foundation import NSBundle
    bundle_path = NSBundle.mainBundle().pathForResource_ofType_(unicode(name), u'bundle')
    objc.loadBundle(name, g, bundle_path=bundle_path)

(I'm using PyObjC 1.4 on Python 2.5 on Tiger, but it should work similarly on Leopard)


On 1/26/08, John Stoner <> wrote:
I am new to Mac/ObjC development, and intermediate in my Python skill.

I have downloaded the Darwiin wii-remote library, and I am trying to integrate it with my  existing application developed in Python. I'm working on a MacBook running Leopard, and I've downloaded XCode 3.0, and fink, and vpython, and a few other things. I can run parts of my app through IDLE successfully.

In XCode, I get these messages during my build and run:

This GDB was configured as "i386-apple-darwin".warning: Unable to read symbols for "@executable_path/../Frameworks/WiiRemote.framework/Versions/A/WiiRemote" (file not found).
Program loaded.
sharedlibrary apply-load-rules all
Attaching to program: `/Users/jstoner/Documents/projects/boogiepants/boogiepants/build/Release/', process 8515.

The Debugger has exited with status 0.
[Session started at 2008-01-22 22:28:09 -0600.]
objc[8633]: Class WiiRemote is implemented in both /Library/Frameworks/WiiRemote.framework/Versions/A/WiiRemote and /Users/jstoner/Documents/projects/boogiepants/boogiepants/build/Release/ Using implementation from /Users/jstoner/Documents/projects/boogiepants/boogiepants/build/Release/
objc[8633]: Class WiiRemoteDiscovery is implemented in both /Library/Frameworks/WiiRemote.framework/Versions/A/WiiRemote and /Users/jstoner/Documents/projects/boogiepants/boogiepants/build/Release/ Using implementation from /Users/jstoner/Documents/projects/boogiepants/boogiepants/build/Release/
Traceback (most recent call last):
  File "/Users/jstoner/Documents/projects/boogiepants/boogiepants/build/Release/", line 17, in <module>
    import boogiepantsAppDelegate
  File "/Users/jstoner/Documents/projects/boogiepants/boogiepants/build/Release/", line 14, in <module>
    from WiiRemote import *
ImportError: No module named WiiRemote

In Idle, I try importing a bunch of libraries (I like IDLE better):

import sys
But I still can't seem to find the right file:

import WiiRemote
ImportError: No module named WiiRemote

I've screwed around a lot trying to get Python to find this library to no avail. Any ideas?
'In knowledge is power, in  wisdom, humility.'
This email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
Pyobjc-dev mailing list