[Pyobjc-dev] More fun with NSTableView
Brought to you by:
ronaldoussoren
From: Mitch C. <mit...@ea...> - 2003-06-04 04:25:13
|
Hi, [Python 2.3b1, PyObjC from CVS, updated less than five minutes ago.] I'm trying to figure out how to supply instances of user-defined Python classes as values for display in an NSTableView, and am stumped again. In the end I'd like to be able to supply one of these Python objects to a subclass of NSCell which extracts rendering information (say, a list of polygon vertices) from the Python objects. I thought I'd start simple: define a Python "value" class which knows how to represent itself as a string. But I didn't start simply enough. Suppose the value class looks like this: class CustomCellValue(NSObject): """Provides the value for a custom cell.""" Suppose the table's data source does this: def tableView_objectValueForTableColumn_row_(self, aTableView, aTableColumn, rowIndex): """Get the object value for a table cell.""" ident = aTableColumn.identifier() result = "%s %s" % (ident, rowIndex) if ident == "custom_column": # Trying to create a simple Python object which is accessible # from OC. result = CustomCellValue.alloc().init() return result When I run the program, I get the following error on the first rendering attempt. 2003-06-03 21:44:02.624 CustomTableCell[15987] *** -[CustomCellValue copyWithZone:]: selector not recognized Traceback (most recent call last): File "/Users/mitchchapman/projects/br/Prototypes/CustomTableCell/build/ CustomTableCell.app/Contents/Resources/__main__.py", line 24, in ? sys.exit(AppKit.NSApplicationMain(sys.argv)) ValueError: NSInvalidArgumentException - *** -[CustomCellValue copyWithZone:]: selector not recognized This looks peculiar because NSObject provides a valid implementation of +copyWithZone:, and the docs say you should not override it. I have verified that my instance actually gets created without incident. It just doesn't seem to understand copyWithZone:. Thanks again for clues. -- Mitch |