[Pyobjc-dev] Re: interface builder queries
Brought to you by:
ronaldoussoren
From: Michael H. <mw...@py...> - 2003-08-29 11:50:50
|
Ronald Oussoren <ous...@ci...> writes: > On vrijdag, 29 augustus 2003, at 11:51AM, Michael Hudson wrote: > >> Michael Hudson <mw...@py...> writes: >> >>> Michael Hudson <mw...@py...> writes: >>> >>>>> Python should also work, as long as IB is single threaded, see the >>>>> EnvironmentPrefs example for a python based plugin. That's a plugin >>>>> for System Preferences, but the mechanics should be simular for IB >>>>> pallettes. >>>> >>>> Right, I'll see if I can blend an IBPalette example with the PyObjC >>>> screensaver example. I'll try to package it up for the Examples/ >>>> directory if I come up with anything useful. >>> >>> Well, after fixing what I think to be a couple of bugs in PyObjC, I've >>> run into another problem. I think. >>> >>> It seems interface builder uses [NSBundle classNamed:] to find the >>> palette class, and my Python classes aren't showing up to this >>> function (it shows up as the result to [NSBundle principalClass], >>> though). >> >> This would seem to be because the objc runtime thinks that Python >> classes are not dynamically loaded (fair enough, but it makes the task >> at hand fairly tricky). >> >> It is odd that you have >> >> NSBundle.bundleForClass(aBundle.principalClass()) != aBundle >> >> though. >> >> Still way over my depth, > > Welcome to the club :-) :-) > Thanks for reminding me of this issue. I had noticed this when > building the preference panes, but didn't think this was very > important at the time. I'll see what I can do about this, this may be > a hard problem. It looks it. There's this intriguingly named function _NSBundleAddClassesAndNotify, but I don't think you're expected to call it... Also, the feeling I get is that there's lot of hacking done to get this sort of thing to work from Java, and it would probably take someone from Apple to do the same for Python. That may be too pessimistic, though. The nicest answer would be arrange for our bundle to load itself into some subclass of NSBundle, but that doesn't look possible (and Mach-O bundles don't even seem to have init sections, which rules out one scary hack that occurred to me). > BTW. I added some code to make it safe to call from Objective-C to > python from any thread, including those without a Python threadstate, > using the API defined in PEP311. The bad news is that I did this in a > tree that contains Panther specific code ;-(. The threadedness of IB doesn't seem to have caused any problems yet (unless that turns out to be responsible for the crashes I saw in PyObjC_GetClassList). Cheers, mwh -- at any rate, I'm satisfied that not only do they know which end of the pointy thing to hold, but where to poke it for maximum effect. -- Eric The Read, asr, on google.com |