#NEWLINE# def __init__( self , parent , tool_bar , image_cache , item , controller , show_labels ) : #NEWLINE# #INDENT# ' Creates a new tool bar tool for an action item. ' #NEWLINE# self . item = item #NEWLINE# self . tool_bar = tool_bar #NEWLINE# action = self . item . action #NEWLINE# label = action . name #NEWLINE# if label . endswith ( '...' ) : #NEWLINE# #INDENT# label = label [ : ( - 3 ) ] #NEWLINE# #UNINDENT# label = label . replace ( '&' , '' ) #NEWLINE# if ( action . image is not None ) : #NEWLINE# #INDENT# image = action . image . create_image ( self . tool_bar . GetToolBitmapSize ( ) ) #NEWLINE# path = action . image . absolute_path #NEWLINE# bmp = image_cache . get_bitmap ( path ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# from pyface.api import ImageResource #NEWLINE# image = ImageResource ( 'foo' ) #NEWLINE# bmp = image . create_bitmap ( ) #NEWLINE# #UNINDENT# kind = _STYLE_TO_KIND_MAP [ action . style ] #NEWLINE# tooltip = action . tooltip #NEWLINE# longtip = action . description #NEWLINE# if ( not show_labels ) : #NEWLINE# #INDENT# label = '' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . tool_bar . SetSize ( ( ( - 1 ) , 50 ) ) #NEWLINE# #UNINDENT# self . control_id = wx . NewId ( ) #NEWLINE# self . control = tool_bar . AddLabelTool ( self . control_id , label , bmp , wx . NullBitmap , kind , tooltip , longtip ) #NEWLINE# tool_bar . ToggleTool ( self . control_id , action . checked ) #NEWLINE# tool_bar . EnableTool ( self . control_id , ( action . enabled and action . visible ) ) #NEWLINE# wx . EVT_TOOL ( parent , self . control_id , self . _on_tool ) #NEWLINE# action . on_trait_change ( self . _on_action_enabled_changed , 'enabled' ) #NEWLINE# action . on_trait_change ( self . _on_action_visible_changed , 'visible' ) #NEWLINE# action . on_trait_change ( self . _on_action_checked_changed , 'checked' ) #NEWLINE# if ( controller is not None ) : #NEWLINE# #INDENT# self . controller = controller #NEWLINE# controller . add_to_toolbar ( self ) #NEWLINE# #UNINDENT# return