class MyTVController(NSObject): tv = objc.IBOutlet() tf = objc.IBOutlet() addButton = objc.IBOutlet() deleteButton = objc.IBOutlet() def awakeFromNib(self): self.L = ['John','Paul','George','Ringo'] self.tv.setDelegate_(self) self.tv.setDataSource_(self) self.tv.reloadData() @objc.IBAction def add_(self,sender): value = self.tf.stringValue() NSLog("add_ %s" % value) i = self.tv.selectedRow() if i == -1: self.L.append(value) else: self.L.insert(i+1,value) self.tv.reloadData() @objc.IBAction def delete_(self,sender): NSLog("delete_")
def numberOfRowsInTableView_(self,tv): return len(self.L) def tableView_objectValueForTableColumn_row_( self,tv,tc,r): return self.L[r]
|