Re: [Pyobjc-dev] Importing custom Objc libraries/frameworks
Brought to you by:
ronaldoussoren
|
From: Ronald O. <ous...@ci...> - 2002-10-27 18:18:35
|
On Saturday, Oct 26, 2002, at 11:18 Europe/Amsterdam, S=E9bastien Pierre=20=
wrote:
> Hi,
>
> I am writing an Objective-C library that I'd like to import and use in=20=
> Python through pyobjc.
>
> Is it possible to do this? If so, what do I have to do to make my=20
> library available to python ?
It is quite easy to do this, assuming that you want to access the=20
classes in the Objective-C library and the library is in a framework.
If your library is installed in the framework=20
'/path/to/mylib.framework' you
can do something like this:
# This is 'mylib.py', a python library for accessing classes
# in 'mylib.framework'
import Foundation
class_list =3D Foundation.load_bundle(
'/path/to/mylib.framework')
gl =3D globals()
for cls in class_list:
gl[cls.__name__] =3D cls
del class_list, cls, gl, Foundation
# end of mylib.py
This will load 'mylib.framework' and export all classes in that=20
framework.
Ronald=
|