Hi,

Some time ago I asked this list for help with a "Newbie problem" which was really about Cocoa rather than PyObjC:  to determine which button of a set of radio buttons (NSMatrix) was selected.  Bob Ippolito kindly suggested the following elegant filter solution (given radioMatrix as an outlet, and getRadio_() as the action to PyAppDelegate:

    def getRadio_(self):
selectedCells = filter(lambda cell: cell.intValue() == 1,
                        self.radioMatrix.cells())

This actually seemed to work 1.5 years ago.  I can't verify that now easily.

Today I had occasion to go back to this code and it clearly has a problem.  The list of cells with intValue() == 1 includes both the currently selected cell and the previously selected one.  Each time I select a new button, I get two positives from the filter, unless I choose the same button twice in a row.  Even selectedCells() is supposed to return both selected and *highlighted* cells, according to the docs.  

In my tests, selectedCells() returns the correct value, but it seems better to use selectedCell().  Or, selectedRow() (for a single column matrix) can also be queried to get the correct value.  I don't know if this is surprising or it's obvious to everybody.  FYI.

Thanks for all your help.  Someday I intend to write a FAVSQ for PyObjC (FA very simple Q).  I think it's wonderful what you've done, but even simple things have taken me quite a while to figure out.  And I think a helpful thing would be to dissect out very simple examples of all common situations.

Tom Elliott
_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to