Disable single option of vanilla RadioGroup?

RoboFont Forums Help / General Disable single option of vanilla RadioGroup?

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by  franz 8 years, 7 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #3833

    franz
    Participant

    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

    #3834

    frederik
    Keymaster

    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

    #3836

    franz
    Participant

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

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.