Re: [Pyobjc-dev] another tableview question
Brought to you by:
ronaldoussoren
From: Phil C. <ph...@bu...> - 2005-07-08 04:52:21
|
Thanks for the help. I've made the changes (the class def is attached below), but I'm still getting the same error. In regards to Bob's response, that syntax for the 'argumentTypes' keyword arg is what's specified in the __doc__ for the obj.selector function. I know that '@' is the symbol for when you're using the 'signature' argument, I tried that as well before using the 'subset of the Py_BuildValue syntax' as specified in the __doc__; I wasn't 'pulling them out of my ass'. One thing I'm not sure about is making the class a dataSource in InterfaceBuilder. I made the connection (and obviously defined the methods in the source), but I couldn't define the appropriate actions on the class I created in IB. When I tried to create an action for 'tableView:objectValueForTableColumn:row:', IB told me it was not a valid action name. I guess that would make sense anyways, since these aren't actions at all. # class defined in MainMenu.nib class ContentsTreeViewDelegate(NibClassBuilder.AutoBaseClass): # the actual base class is NSObject # The following outlets are added to the class: # controller # tableView def init(self): self = super(ContentsTreeViewDelegate, self).init() self.contents = [] return self def numberOfRowsInTableView_(self, sender): return len(self.contents) def tableView_objectValueForTableColumn_row_(self, sender, tableColumn, row): return self.contents[row] On Jul 8, 2005, at 12:10 AM, Dethe Elza wrote: [snip snip snip] >> def awakeFromNib(self): >> self.tableView.documentView().setDataSource_(self) >> > > You can (and perhaps should) set the data source in your nib using > InterfaceBuilder. > [snip snip snip] >> def tableView_objectValueForTableColumn_row_(self, sender, >> tableColumn, row): >> if (len(self.contents) > row): >> self.contents[row] >> tableView_objectValueForTableColumn_row_ = objc.selector >> (tableView_objectValueForTableColumn_row_, >> >> argumentTypes='OOi', >> >> returnType='O') >> >> > > I think this may be the problem, you're not returning a value from > this method. Also, the value you return should inherit from > NSObject, and you should keep a reference to it, because the > tableView doesn't, IIRC. > > > >> ################################# >> >> but when I run the application I get: >> >> 2005-07-07 22:19:30.911 controller[7740] *** Illegal NSTableView >> data source (<ContentsTreeViewDelegate: 0x11ac760>). Must >> implement numberOfRowsInTableView: and >> tableView:objectValueForTableColumn:row: >> >> > > I think this is due to you not returning a value from the method > above. Try it and see. > > |