Re: [Pyobjc-dev] Customizing trouble with NSCell & NSTableView
Brought to you by:
ronaldoussoren
From: Mitch C. <mit...@ea...> - 2003-05-20 13:08:26
|
On Tuesday, May 20, 2003, at 06:24 AM, Dinu Gherman wrote: > Hi, > > I'm trying to use NSTableView delegate method for changing the > background of individual cells. The method name is this one: > > tableView_willDisplayCell_forTableColumn_row_(self, > view, cell, col, row) > > But I always seem to receive a None value for the row argument > and even if the method returns and does nothing else my app > just crashes with a "signal 10 (SIGBUS)". Hi Dinu, The problem you describe looks like the problems I've had in creating an NSTableDataSource. The solution seems to be to explicitly derive your delegate class from NSTableViewDelegate. To test I started from a Cocoa-Python application, adding an NSTableView and wiring up the MyAppDelegate instance as the table's delegate. The first run behaved exactly as you described. After adding from AppKit import NSTableViewDelegate and class MyAppDelegate(..., NSTableViewDelegate): the tableView_willDisplayCell_forTableColumn_row_ method started getting an integer for the row, rather than None; and it stopped crashing. This may already be listed in the PyObjC FAQ, but it seems that, in general, if you want to implement an AppKit protocol in a Python class, you must explicitly declare that protocol as a base class of your Python class. Else you get un-Pythonic segfaults and bus errors. -- Mitch |