[Pythonmac-SIG] Newbie PyObjC question

Bob Ippolito bob at redivi.com
Sun Nov 7 20:19:45 CET 2004

On Nov 7, 2004, at 12:01, Tom Elliott wrote:

> I would like to know how to determine which of several radio buttons 
> has been selected by the user, preferably in a simple variable like an 
> int.  I can set the buttons as an action for my Controller, and be 
> told when the user pushes a button, but there's no info about which 
> button was pushed.
> In the case of a slider, one can set the slider to be an outlet for 
> the Controller and get the value by:
> value = self.mySlider.doubleValue()
> What is the corresponding call for a set of buttons?  I can't figure 
> out anything from the Apple APIs.
> Thanks a lot for any help.

Give each radio button (a NSButtonCell) a tag, or just give them all 
meaningful titles.  Make an outlet for your NSMatrix of NSButtonCells 
(radio buttons).  To see which cells are selected you can do:

selectedCells = filter(lambda cell: cell.intValue() == 1, 

and then you'd get the title or tag from your selected cells.


More information about the Pythonmac-SIG mailing list