Thread: [Pyobjc-dev] problem with NSTableView
Brought to you by:
ronaldoussoren
From: chris b. <por...@ya...> - 2003-03-13 19:56:45
|
Hello, I'm currently experiencing an error with my program which lead to the following getting outputted to the console 2003-03-07 21:14:33.618 whisper[508] Application did finish launching. 2003-03-07 21:15:09.902 whisper[508] *** Assertion failure in -[NSTableView _locationOfRow:], TableView.subproj NSTableView.m:486 2003-03-07 21:15:10.028 whisper[508] NSInternalInconsistencyException I haven't actually been able to find the _locationOfRow: method in any of Apple's documentation or the web. I guess it must be a private call to do with the way that the object renders itself to screen. So if any of you know what this actually is so I can figure out what is going wrong that would be very useful. I'm programming in Python and bridging to Cocoa with the PyObjC module (version 0.8). This NSTableView instance is pure Obj-C and was created via Interface builder. The error occurs when setting the datasource of the NSTableView object using the following Python code. self.knownEntitiesTable.setDataSource_(self.knownEntities) self.knownEntities is a Python object that inheriting from NSObject and implementing the informal NSTableDataSource protocol. At this point it contains no data to display as I'm just setting the program up at this point. Any help that you can give would be greatly appreciated. Thanks in advance. Chris here is the python code of the knownEntities Object that acts as the datasource. class entityTable(NSObject): identitiesList = [] counter = 0 def numberOfRowsInTableView_(self): NSLog(str(self.counter)) return self.counter def tableView_objectValueForTableColumn_row_(self, tableView, tableColumn, row): NSLog(self.identitiesList[row].name) return self.identitiesList[row].name def tableView_setObjectValue_forTableColumn_row_(self, tableView, id, tableColumn, row): self.identitiesList.insert(row,id) def setIdentity(self,id,row): if row < len(self.identities): self.identitiesList[row] = id else: self.identitiesList.append(id) self.counter += 1 def setIdentities(self,ids): self.counter = len(ids) self.identitiesList = ids def getIdentity(self,row): return self.identitiesList[row] def getIdentities(self): return self.identitiesList def append(self,id): self.counter += 1 self.identitiesList.append(id) #it has been very insistent about these two methods def __len__(self): return self.counter def __getitem__(self, key): return self.identitiesList[key] __________________________________________________ Do you Yahoo!? Yahoo! Web Hosting - establish your business online http://webhosting.yahoo.com |
From: <bo...@pa...> - 2003-03-13 20:07:38
|
there are issues right off the bat that you will need to resolve: first, declare the "informal" protocol NSTableDataSource, like this: class entityTable(AutoBaseClass, NSTableDataSource): second, there are enough bugs in 0.8 with NSTables, that you are better off building from scratch out of the CVS depot. make sure you build FFI first and follow the FFI build/install instructions exactly [especially the part about creating and cd'ing into the build directory]. --bob On Thursday, March 13, 2003, at 11:56 AM, chris bunker wrote: > Hello, I'm currently experiencing an error with my > program which lead to the following getting outputted > to the console > > 2003-03-07 21:14:33.618 whisper[508] Application did > finish launching. > 2003-03-07 21:15:09.902 whisper[508] *** Assertion > failure in -[NSTableView _locationOfRow:], > TableView.subproj NSTableView.m:486 > 2003-03-07 21:15:10.028 whisper[508] > NSInternalInconsistencyException > > I haven't actually been able to find the > _locationOfRow: method in any of Apple's documentation > or the web. I guess it must be a private call to do > with the way that the object renders itself to screen. > So if any of you know what this actually is so I can > figure out what is going wrong that would be very > useful. > > I'm programming in Python and bridging to Cocoa with > the PyObjC module (version 0.8). This NSTableView > instance is pure Obj-C and was created via Interface > builder. > > The error occurs when setting the datasource of the > NSTableView object using the following Python code. > > self.knownEntitiesTable.setDataSource_(self.knownEntities) > > self.knownEntities is a Python object that inheriting > from NSObject and implementing the informal > NSTableDataSource protocol. At this point it contains > no data to display as I'm just setting the program up > at this point. > > Any help that you can give would be greatly > appreciated. Thanks in advance. > > Chris > > here is the python code of the knownEntities Object > that acts as the datasource. > > class entityTable(NSObject): > identitiesList = [] > counter = 0 > > def numberOfRowsInTableView_(self): > NSLog(str(self.counter)) > return self.counter > > def tableView_objectValueForTableColumn_row_(self, > tableView, tableColumn, row): > NSLog(self.identitiesList[row].name) > return self.identitiesList[row].name > > def > tableView_setObjectValue_forTableColumn_row_(self, > tableView, id, tableColumn, row): > self.identitiesList.insert(row,id) > > def setIdentity(self,id,row): > if row < len(self.identities): > self.identitiesList[row] = id > else: > self.identitiesList.append(id) > self.counter += 1 > > def setIdentities(self,ids): > self.counter = len(ids) > self.identitiesList = ids > > def getIdentity(self,row): > return self.identitiesList[row] > > def getIdentities(self): > return self.identitiesList > > def append(self,id): > self.counter += 1 > self.identitiesList.append(id) > > #it has been very insistent about these two > methods > def __len__(self): > return self.counter > > def __getitem__(self, key): > return self.identitiesList[key] > > __________________________________________________ > Do you Yahoo!? > Yahoo! Web Hosting - establish your business online > http://webhosting.yahoo.com > > > ------------------------------------------------------- > This SF.net email is sponsored by:Crypto Challenge is now open! > Get cracking and register here for some mind boggling fun and > the chance of winning an Apple iPod: > http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > |
From: <bb...@ma...> - 2003-03-13 20:07:54
|
On Thursday, Mar 13, 2003, at 14:56 US/Eastern, chris bunker wrote: .... > self.knownEntities is a Python object that inheriting > from NSObject and implementing the informal > NSTableDataSource protocol. At this point it contains > no data to display as I'm just setting the program up > at this point. > > .... > class entityTable(NSObject): ... Change the declaration to: > class entityTable(NSObject, NSTableDataSource): (BTW: Normally, that class would be called 'EntityTable' to be consistent w/ObjC and Python naming conventions.) -- When implementing one of the informal protocols, you need to specifically declare [in Python] that you are doing so. This allows PyObjC to figure out the correct types for the arguments to the method. The alternative is to use the objc.selector() function to declare the appropriate types on the methods -- but that is considerably more tedious. I posted a relatively long message a few days [weeks?] ago that explains informal protocols and their implementation in Python via PyObjC -- see the list archives. b.bum (Stuck in Cocoa/Java land right now.... makes me appreciate Cocoa/Python all the more) |
From: Ronald O. <ous...@ci...> - 2003-03-13 20:08:00
|
On Thursday, Mar 13, 2003, at 20:56 Europe/Amsterdam, chris bunker wrote: > Hello, I'm currently experiencing an error with my > program which lead to the following getting outputted > to the console > here is the python code of the knownEntities Object > that acts as the datasource. > > class entityTable(NSObject): There's your problem. You should also inherit from NSTableDataSource: class entityTable(NSObject, NSTableDataSource): ... This is necessary to make sure that the bridge knows the right method signatures for Objective-C: A number of the methods in the datasource protocol use plain C types as arguments or return value, without this hint the bridge assumes that all arguments and return values are objects. Ronald |
From: Martina O. <Ma...@Oe...> - 2003-03-13 20:14:46
|
Hi Chris, > here is the python code of the knownEntities Object > that acts as the datasource. > > class entityTable(NSObject): > change this to: from AppKit import NSTableDataSource class entityTable(NSTableDataSource): PyObjc needs to know the method signatures (parameter and return types). If it doesn't know them it assumes they are of type ID, which causes the crash. The NSTableDataSource class declares the proper method signatures signatures for you. ciao Martina |