Re: [Pyobjc-dev] How do I learn PyObjC 2 in Leopard?
Brought to you by:
ronaldoussoren
|
From: Jon R. <ch...@gm...> - 2007-12-20 16:15:38
|
On Dec 20, 2007 1:56 AM, Michael McCracken <mic...@gm...> wrote:
> The main changes that tripped me up are that to benefit from the IB
> integration (I think) you need to use the XIB format, and you want to
> declare your class ivars as IBOutlet, and methods as IBAction when
> appropriate, like you do in ObjC:
>
> from objc import IBOutlet, IBAction
>
> class SomeWindowController(NSWindowController):
> myProgressMeter = IBOutlet()
>
> @IBAction
> def haveAHollyJollyChristmas_(self, sender):
> # etc...
>
> Then IB will see these just like it does with ObjC IBAction/Outlets,
> and you'll hook up your UI like you would for ObjC.
I did figure out where to get IBOutlet and IBAction, but my
ConverterController (I'm following the Currency Converter tutorial)
doesn't seem to be working. When the app starts up, it puts this in
the console:
12/20/07 10:09:29 AM Python Converter Converter[9448] Unknown class
`ConverterController' in nib file, using `NSObject' instead.
12/20/07 10:09:29 AM Python Converter Converter[9448] Could not
connect the action convert: to target of class NSObject
and then obviously clicking the convert button doesn't do anything at all.
Here is my ConverterController class:
class ConverterController(NSObject):
amountField = objc.IBOutlet()
dollarField = objc.IBOutlet()
rateField = objc.IBOutlet()
@objc.IBAction
def convert_(self, sender):
print "Hello World"
self.amountField.setFloatValue_(self.dollarField.floatValue()
* self.rateField.floatValue())
self.rateField.selectText_(self)
|