[Pyobjc-dev] Confused on syntax
Brought to you by:
ronaldoussoren
|
From: Deirdre S. M. <de...@de...> - 2001-04-27 18:09:05
|
I realize that I asked Steve a lot of questions and others might be
able to answer and/or shed some light on. My ObjC was never really
very good (I'm trying to work on that <g>) and I'm trying to make the
paradigm leap at the same time.
I'm trying to create a Python version of the Currency Converter
tutorial (start smallish, I figured). I figured I'd keep the two
classes (Converter and ConverterController) as intended and wrestle
with the main function after that, cribbing heavily from Steve.
Converter.py looks right (and the python interpreter doesn't
complain). But when it gets to the ConverterController class (where
all the fun is), my understanding just stops cold.
The .h file is:
#import <Cocoa/Cocoa.h>
@interface ConverterController : NSObject
{
IBOutlet id converter;
IBOutlet id dollarField;
IBOutlet id rateField;
IBOutlet id totalField;
}
- (IBAction)convert:(id)sender;
@end
It seems to me that this has got to have a syntax something like:
# ConverterController.py
import pyobjc
import Converter
class ConverterController(pyobjc.runtime.NSObject):
def __init__(self):
self.converter = pyobjc.runtime.IBOutlet(id)
self.dollarField = pyobjc.runtime.IBOutlet(id)
self.rateField = pyobjc.runtime.IBOutlet(id)
self.totalField = pyobjc.runtime.IBOutlet(id)
def convert(sender):
amt = self.dollarField.floatValue()
rate = self.rateField.floatValue()
total = self.converter( amt, rate )
self.totalField.setFloatValue(total)
self.rateField.selectText(self.rateField)
Am I even close here?
|