#NEWLINE# def __init__( self , master , gradient_table , color_space , width , height , on_table_changed = None ) : #NEWLINE# #INDENT# tk . Frame . __init__ ( self , master , borderwidth = 2 , relief = 'groove' ) #NEWLINE# "Initialize a function control widget on tkframe master.\n\n        input:\n        OnTableChanged: Callback function taking a bool argument of meaning\n            'FinalUpdate'. FinalUpdate is true if a control point is dropped,\n            created or removed and false if the update is due to a control point\n            currently beeing dragged (but not yet dropped)\n        ColorSpace: String which specifies the channels painted on this control.\n             May be any combination of h,s,v,r,g,b,a in which each channel\n             occurs only once." #NEWLINE# self . on_table_changed = on_table_changed #NEWLINE# self . table = gradient_table #NEWLINE# self . width = width #NEWLINE# self . height = height #NEWLINE# self . gradient_table = gradient_table #NEWLINE# self . canvas = tk . Canvas ( self , background = 'white' , width = self . width , height = self . height ) #NEWLINE# self . canvas . pack ( ) #NEWLINE# self . channels = [ ] #NEWLINE# Channel = FunctionControl . Channel #NEWLINE# for c in color_space : #NEWLINE# #INDENT# if ( c == 'r' ) : #NEWLINE# #INDENT# self . channels += [ Channel ( self , 'r' , 'red' , 0 , 'rgb' ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( c == 'g' ) : #NEWLINE# #INDENT# self . channels += [ Channel ( self , 'g' , 'green' , 1 , 'rgb' ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( c == 'b' ) : #NEWLINE# #INDENT# self . channels += [ Channel ( self , 'b' , 'blue' , 2 , 'rgb' ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( c == 'v' ) : #NEWLINE# #INDENT# self . channels += [ Channel ( self , 'v' , '#7f7f7f' , 2 , 'hsv' ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( c == 'h' ) : #NEWLINE# #INDENT# self . channels += [ Channel ( self , 'h' , '#ff0000' , 0 , 'hsv' ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( c == 's' ) : #NEWLINE# #INDENT# self . channels += [ Channel ( self , 's' , '#ffafaf' , 1 , 'hsv' ) ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( c == 'a' ) : #NEWLINE# #INDENT# self . channels += [ Channel ( self , 'a' , '#000000' , 3 , 'hsv' ) ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# self . active_channels_string = '' #NEWLINE# for channel in self . channels : #NEWLINE# #INDENT# self . active_channels_string += channel . name #NEWLINE# #UNINDENT# if ( ( 'r' in color_space ) or ( 'g' in color_space ) or ( 'b' in color_space ) ) : #NEWLINE# #INDENT# for c in 'hsv' : #NEWLINE# #INDENT# if ( not ( c in self . active_channels_string ) ) : #NEWLINE# #INDENT# self . active_channels_string += c #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( color_space == 'a' ) : #NEWLINE# #INDENT# self . active_channels_string = 'a' #NEWLINE# #UNINDENT# self . update ( ) #NEWLINE# self . canvas . bind ( '<ButtonRelease-1>' , self . on_left_button_up ) #NEWLINE# self . canvas . bind ( '<Button-1>' , self . on_left_button_down ) #NEWLINE# self . canvas . bind ( '<ButtonRelease-3>' , self . on_right_button_up ) #NEWLINE# self . canvas . bind ( '<Button-3>' , self . on_right_button_down ) #NEWLINE# self . canvas . bind ( '<Motion>' , self . on_mouse_move ) #NEWLINE# self . cur_drag = None