Commits

Anonymous committed dde8597

Attempt to package up Cocoa classes in Foundation & AppKit.
so you can do "from Cocoa import *" or
"from Cocoa.Foundation import *"
2002-1-26 sdm7g

  • Participants
  • Parent commits 6511cae

Comments (0)

Files changed (3)

pyobjc/Examples/Cocoa/AppKit.py

+import pyobjc
+from Cocoa import Foundation
+
+
+def LoadBundle( path ):
+        bundle = Foundation.NSBundle.bundleWithPath_( path )
+        bundle.load()
+        return bundle
+
+
+# load AppKit so those classes are available for inspection
+AppKitBundle = LoadBundle( '/System/Library/Frameworks/AppKit.framework')
+
+__AppKit__ = globals()
+for _name in dir(pyobjc.runtime):
+    if _name[0] <> '_' and _name not in dir(Foundation)+Foundation.__skip__:
+		__AppKit__[_name] = pyobjc.lookup_class(_name)
+
+del _name
+
+
+

pyobjc/Examples/Cocoa/Foundation.py

+
+import pyobjc
+
+__Foundation__ = globals()
+__skip__ = [ 'NSInvocationBuilder', 'sel_is_mapped' ]
+
+for _name in dir(pyobjc.runtime):
+    if _name[0] <> '_' and _name not in __skip__:
+        __Foundation__[_name] =  pyobjc.lookup_class(_name) 
+
+sel_is_mapped = pyobjc.runtime.sel_is_mapped 
+del _name
+
+
+
+

pyobjc/Examples/Cocoa/__init__.py

+
+import pyobjc
+
+_Pool = pyobjc.runtime.NSAutoreleasePool()
+
+__all__ = [ 'Foundation', 'AppKit' ]
+
+
+