From: Deirdre S. M. <de...@de...> - 2001-05-12 04:42:44
|
Based on some of the stuff that Steven Majewski did, trying to create a Cocoa app that loads a nib from Jython. When running, I get the following errors: % jython CurrencyConverter.jy ( NSBundle </System/Library/Frameworks/Foundation.framework> (loaded), NSBundle </usr/lib> (loaded), NSBundle </System/Library/Frameworks/JavaVM.framework> (loaded), NSBundle </usr/lib/java> (loaded) ) ./build/CurrencyConverter2.app May 11 21:35:32 java[1110] Unknown class `ConverterController' in nib file, using `NSObject' instead. May 11 21:35:32 java[1110] Unknown class `Converter' in nib file, using `NSObject' instead. May 11 21:35:32 java[1110] Could not connect the action convert: to target of class NSObject So...why doesn't it know about the classes? #!/usr/bin/env jython from com.apple.cocoa.foundation import * from com.apple.cocoa.application import * MyApp = None _pools = [] tpath = './TempConverter/build/TempConverter.app' cpath = './build/CurrencyConverter2.app' class Converter(NSObject): def convert(amount, rate): return (amount * rate) class ConverterController(NSObject): def __init__(): self.converter = Converter() self.dollarField = NSTextField() self.rateField = NSTextField() self.totalField = NSTextField() def convert(sender): rate = self.rateField.floatValue(); amount = self.dollarField.floatValue(); total = converter.convert(amount, rate); self.totalField.setFloatValue(total); def xxx(): print NSBundle.allFrameworks() def Pool(): global _pools tmp = NSAutoreleasePool.push() _pools.append(tmp) return tmp def App(): global MyApp MyApp = NSApplication.sharedApplication() return MyApp def Bundle( path=cpath ): print path return NSBundle.bundleWithPath( path ) xxx() pool = Pool() myapp = App() bndl = Bundle() nib = NSApplication.loadNibFromBundle( bndl, 'MainMenu', myapp ) if __name__ == '__main__' : myapp.run() |