Re: [Pythonmac-SIG] [Pyobjc-dev] another tableview question
On Friday, July 08, 2005, at 06:40AM, Bob Ippolito [EMAIL PROTECTED] wrote: On Jul 7, 2005, at 6:10 PM, Dethe Elza wrote: On 7-Jul-05, at 7:29 PM, Phil Christensen wrote: def numberOfRowsInTableView_(self, sender): return (len(self.contents)) numberOfRowsInTableView_ = objc.selector (numberOfRowsInTableView_, argumentTypes='O', returnType='i') I have never needed to use objc.selector. I think this method should be OK without it. Since the types are specified by an existing class in the runtime, you definitely don't need or want to specify something else. The objc.selector(...) is actually breaking things, because you can't just pull type codes out of your ass and expect it to do the right thing. 'O' doesn't mean object, '@' does.\ This is actually correct, although it could be said that the functionality sucks :-( The argumentTypes and returnType arguments of selector get PyArg_Parse-style type specifiers. I wouldn't be surprised if this code is barely tested, I never used the functionality although it looked like a great idea at the time. # 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 because you're using bogus type codes. Don't use objc.selector unless you need to AND know what you're doing ;) -bob --- This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual core and dual graphics technology at this free one hour event hosted by HP, AMD, and NVIDIA. To register visit http://www.hp.com/go/dualwebinar ___ Pyobjc-dev mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/pyobjc-dev ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] [Pyobjc-dev] another tableview question
On 7-Jul-05, at 7:29 PM, Phil Christensen wrote: # # 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.contents = [] return self You should call your superclass init() here. Bob Ippolito wrote about proper use of super on this list a few days ago, so I'm paraphrasing from him: def init(self): self = super(ontentsTreeViewDelegate, self).init() self.contents = [] return self def awakeFromNib(self): self.tableView.documentView().setDataSource_(self) You can (and perhaps should) set the data source in your nib using InterfaceBuilder. def numberOfRowsInTableView_(self, sender): return (len(self.contents)) numberOfRowsInTableView_ = objc.selector(numberOfRowsInTableView_, argumentTypes='O', returnType='i') I have never needed to use objc.selector. I think this method should be OK without it. 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. Which I thought I had! Incidentally, I've also tried defining the selector with and without the 'selector' argument, and I've also tried using the 'signature' argument instead of the argumentTypes/ returnType keywords. You shouldn't need these, the PyObjC does a great job of hiding these details. Any help would be greatly appreciated. Thanks in advance, -phil christensen [EMAIL PROTECTED] --Dethe Windows has detected the mouse has moved. Please restart your system for changes to take effect. ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] [Pyobjc-dev] another tableview question
On Jul 7, 2005, at 6:10 PM, Dethe Elza wrote: On 7-Jul-05, at 7:29 PM, Phil Christensen wrote: def numberOfRowsInTableView_(self, sender): return (len(self.contents)) numberOfRowsInTableView_ = objc.selector (numberOfRowsInTableView_, argumentTypes='O', returnType='i') I have never needed to use objc.selector. I think this method should be OK without it. Since the types are specified by an existing class in the runtime, you definitely don't need or want to specify something else. The objc.selector(...) is actually breaking things, because you can't just pull type codes out of your ass and expect it to do the right thing. 'O' doesn't mean object, '@' does. # 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 because you're using bogus type codes. Don't use objc.selector unless you need to AND know what you're doing ;) -bob ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig
Re: [Pythonmac-SIG] [Pyobjc-dev] another tableview question
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. You don't have to tell IB about actions unless you want to bind them. In this case, all you need to do is tell it you have this custom class, and an instance of your class is the dataSource for your table. The rest should happen at runtime. --Dethe Thought is an infection. In certain cases it becomes an epidemic. -- Wallace Stevens ___ Pythonmac-SIG maillist - Pythonmac-SIG@python.org http://mail.python.org/mailman/listinfo/pythonmac-sig