On Mar 8, 2005, at 10:54, Florian Munz wrote:
Bob Ippolito <[EMAIL PROTECTED]> wrote:
It's automatically generated from the Xcode project and is a relatively
general solution, so it's not minimal. Works fine with --alias here,
you should try it with py2app svn trunk.
Okay, since I'm am not using XCode I thought there must be a simpler way.
There is, but not much simpler. You still have to build an extension that the Objective-C code is going to live in. If it was a pre-built framework or plug-in it would be a different story, but compiling one of those is harder than having distutils build an extension.
You probably can use any Python class, but the most well tested solution is to use a NSObject subclass whenever you have code that is going to be called from Objective-C, so I would recommend doing that.
I tried subclassing NSObject but now I am not sure about the right way to create an object. Take this minimal example:
class Converter (NSObject): def init(self): self = NSObject.init(self) NSWorkspace.sharedWorkspace().notificationCenter(). addObserver_selector_name_object_( self, "documentChanged:", None, None) return self
def documentChanged_(self, notification): print 'handleChange'
If I instantiate this class from the Main-Class with
Converter.alloc().init() my application dies quickly (Crash Reporter,
nothing in the logs). If I however instantiate it from Interface Builder
it works. Is this a bug or a feature? :)
I don't want to instantate it from IB, because I have 4 of these classes
and don't need all of them everytime.
You forgot to specify WHICH notification in Converter.. you're saying "add my documentChanged: selector as an observer to... nothing".
Also, use self = super(Converter, self).init()
-bob
_______________________________________________ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig