Re: [Pyobjc-dev] Embedding in Apps & Loading preferences Bundles
Brought to you by:
ronaldoussoren
From: <bb...@ma...> - 2002-11-25 13:37:54
|
On Monday, November 25, 2002, at 08:02 AM, Ronald Oussoren wrote: > Some time in the future I will probably try to write whatever is > needed to get prefpanes to work. That is probably simular to what is > needed to write plugins for programs that use Objective-C classes as > plugins (e.g. which is basicly what the system preferences application > is doing). I probably won't work on forcing this onto unwilling > applications. I.e. implement an application that implements enough of the various classes in Python that are required to make a loaded preferences panel work in some place other than System Preferences? Or create a plugin type architecture for new apps? In the first case, Outside of it being an excellent test of the bridge, is the goal to provide the user with standalone prefs apps? Neat idea. Key challenge: The classes that are subsequently subclassed by the loaded module must have instance variables that look/feel/act exactly like the iVars in the original parent class.... In the second case, there isn't really anything to do -- it already "just works" (and is analogous to what a couple of my apps are doing when they mixin ObjC code as frameworks within the app wrapper). You will need to create ObjC headers that declare the classes that are defined in Python that will be subclassed in the bundle (mostly for the iVars, but also just to compile a subclass). To compile the bundle will likely require an '-undefined suppress' option.... > Finding a way to automaticly execute a function when 'our' shared > library is loaded will probably the most problematic part of this. > That is: Whenever the 'pyobjcextension' shared libary is loaded > 'initPyObjCExtension' in that library should run. I haven't looked > into this yet and this may well be either trivial or impossible. Assuming that the target application is ObjC, simply creating a +(void)load in a class/category within the dylib should be enough to cause a hunk of code to be executing that can call -initPyObjCExtension. There is also a similar mechanism in the pure C++ world. In any case, embedding Python as an extension to existing applications would require a build of Python other than Apple's. Not really a big deal -- completely different situation than creating a standalone python App (though it would be nice to have an app extension that doesn't require a multi-MB download because it includes a python distribution). b.bum |