

def __menuDefinition(self):
    with self.getContext():
        try:
            selectedChannels = self.getPlug().getValue()
        except:
            selectedChannels = IECore.StringVectorData()
        try:
            availableChannels = self.__imagePlug['channelNames'].getValue()
        except:
            availableChannels = IECore.StringVectorData()
    result = IECore.MenuDefinition()
    for channel in availableChannels:
        channelSelected = (channel in selectedChannels)
        if channelSelected:
            newValue = IECore.StringVectorData([c for c in selectedChannels if (c != channel)])
        else:
            newValue = IECore.StringVectorData([c for c in availableChannels if ((c in selectedChannels) or (c == channel))])
        result.append(('/' + channel.replace('.', '/')), {
            'command': functools.partial(Gaffer.WeakMethod(self.__setValue), value=newValue),
            'checkBox': channelSelected,
        })
    return result

dataset/ETHPy150Open ImageEngine/gaffer/python/GafferImageUI/ChannelMaskPlugValueWidget.py ChannelMaskPlugValueWidget.__menuDefinition/original