SOLVED Disable single option of vanilla RadioGroup?



  • Hi,

    I've trawled through the Vanilla Object Inspector but couldn't find anything, so here goes:

    I have a RadioGroup with three items/options. One of those is only available once certain conditions are met, so I was wondering if it was possible to target and disable a single option of a RadioGroup?

    I guess I could update the RadioGroup once the condition changes and either display the option/item in question or not display it at all, but I'd much prefer it to be there, but disabled, so the user knows this option does (conditionally) exist.

    Any pointers/leads?

    Many thanks,
    Franz



  • Yes, this is exactly what I need right now! Thanks so much Frederik!
    Franz


  • admin

    If I understood it correctly your want to disable (grayed out) an option in a RadioGroup.

    from vanilla import *
    
    class Test:
        
        def __init__(self):
            
            self.w = Window((400, 400))
            
            self.w.allOptions = CheckBox((10, 10, -10, 22), "All Options", callback=self.allOptionsCallback)
            self.w.radioButtons = RadioGroup((10, 40, -10, 80), ["option 1", "option 2", "option 3"])
            
            self.w.radioButtons.getNSMatrix().cellAtRow_column_(2, 0).setEnabled_(False)
            
            self.w.open()
        
        def allOptionsCallback(self, sender):
            self.w.radioButtons.getNSMatrix().cellAtRow_column_(2, 0).setEnabled_(sender.get())
            
    Test()
    

    hope this helps