#NEWLINE# def __menuDefinition( self ) : #NEWLINE# #INDENT# with self . getContext ( ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# selectedChannel = self . getPlug ( ) . getValue ( ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# selectedChannels = '' #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# availableChannels = self . __imagePlug [ 'channelNames' ] . getValue ( ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# availableChannels = [ ] #NEWLINE# #UNINDENT# #UNINDENT# if ( self . getPlug ( ) . getName ( ) == 'in' ) : #NEWLINE# #INDENT# availableChannels . extend ( [ '__white' , '__black' ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# for channel in ( 'R' , 'G' , 'B' , 'A' ) : #NEWLINE# #INDENT# if ( channel not in availableChannels ) : #NEWLINE# #INDENT# availableChannels . append ( channel ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# result = IECore . MenuDefinition ( ) #NEWLINE# for channel in availableChannels : #NEWLINE# #INDENT# if ( channel == '__white' ) : #NEWLINE# #INDENT# result . append ( '/__Divider' , { #NEWLINE# #INDENT# 'divider' : True , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# result . append ( ( '/' + self . __channelLabel ( channel ) . replace ( '.' , '/' ) ) , { #NEWLINE# #INDENT# 'command' : functools . partial ( Gaffer . WeakMethod ( self . __setValue ) , value = channel ) , #NEWLINE# 'checkBox' : ( selectedChannel == channel ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# return result