

def __menuDefinition(self):
    result = IECore.MenuDefinition()
    if (self.getPlug() is None):
        return result
    formats = [GafferImage.Format.format(n) for n in GafferImage.Format.registeredFormats()]
    if (not self.getPlug().ancestor(Gaffer.ScriptNode).isSame(self.getPlug().node())):
        formats.insert(0, GafferImage.Format())
    currentFormat = self.getPlug().getValue()
    modeIsCustom = (Gaffer.Metadata.plugValue(self.getPlug(), 'formatPlugValueWidget:mode') == 'custom')
    for fmt in formats:
        result.append(('/' + self.__formatLabel(fmt)), {
            'command': functools.partial(Gaffer.WeakMethod(self.__applyFormat), fmt=currentFormat),
            'checkBox': ((fmt == currentFormat) and (not modeIsCustom)),
        })
    result.append('/CustomDivider', {
        'divider': True,
    })
    result.append('/Custom', {
        'command': Gaffer.WeakMethod(self.__applyCustomFormat),
        'checkBox': (modeIsCustom or (currentFormat not in formats)),
    })
    return result

dataset/ETHPy150Open ImageEngine/gaffer/python/GafferImageUI/FormatPlugValueWidget.py FormatPlugValueWidget.__menuDefinition/VarMisuse@178/239 `fmt`->`currentFormat`