Bob Ippolito (@etrepum) on Haskell, Python, Erlang, JavaScript, etc.

More to look forward to in PyObjC 1.3


Lots of nice new things went into PyObjC the past few days:

  • New HotKeyPython example in AppKit that demonstrates how to use Carbon global hot keys from a PyObjC application. Also demonstrates how to use a NSApplication subclass.
  • Key-Value Observing support is now automatic in Python classes that descend from NSObject, unless they implement a custom willChangeValueForKey:, didChangeValueForKey:, or __useKVO__ is not True. This allows = 1 to automatically trigger notifications. This works in all cases, whether foo is a property, ivar, or just in the __dict__.

This should make writing Cocoa Bindings applications a whole heck of a lot easier...

  • New Inject folder in Examples, with a PyInterpreter example that will inject a GUI Python interpreter into any process.
  • New objc.inject() function for Mac OS X 10.3 and later, allows an arbitrary bundle to be loaded into another process using mach_inject.

objc.inject() can be used to implement some really interesting things, such as a "pdb attach" into a separate process, or a "Python Anywhere" like F-Script Anywhere.

  • objc.classAddMethods now recognizes and supports classmethods.
  • GC is now correctly implemented for struct wrappers.
  • The NSNumber bridge has been removed, now you will get NSNumber instances across the bridge instead of a Python representation.

This allows you do use Objective-C conventions for dealing with numbers, i.e. someNumber.doubleValue(). The reason I did this was because NSNumber only keeps track of the "basic type" of the value that goes in, so it will "forget" if the value was unsigned. Since Python is really bad at emulating C conventions for signed/unsigned numbers, this was the obvious way to fix it.

blog comments powered by Disqus