@@ -3244,7 +3244,8 @@ def __init__(self, name, sender, tool, canvasevent=None, data=None):
32443244
32453245
32463246class  NavigationMessageEvent (object ):
3247-     """Event carrying messages from navigation 
3247+     """ 
3248+     Event carrying messages from navigation 
32483249
32493250    Messages usually get displayed to the user by the toolbar 
32503251    """ 
@@ -3255,7 +3256,8 @@ def __init__(self, name, sender, message):
32553256
32563257
32573258class  NavigationBase (object ):
3258-     """Helper class that groups all the user interactions for a FigureManager 
3259+     """ 
3260+     Helper class that groups all the user interactions for a FigureManager 
32593261
32603262    Attributes 
32613263    ---------- 
@@ -3281,7 +3283,8 @@ def __init__(self, canvas):
32813283        self .messagelock  =  widgets .LockDraw ()
32823284
32833285    def  nav_connect (self , s , func ):
3284-         """Connect event with string *s* to *func*. 
3286+         """ 
3287+         Connect event with string *s* to *func*. 
32853288
32863289        Parameters 
32873290        ----------- 
@@ -3306,7 +3309,8 @@ def func(event)
33063309        return  self ._callbacks .connect (s , func )
33073310
33083311    def  nav_disconnect (self , cid ):
3309-         """Disconnect callback id cid 
3312+         """ 
3313+         Disconnect callback id cid 
33103314
33113315        Example usage:: 
33123316
@@ -3317,7 +3321,7 @@ def nav_disconnect(self, cid):
33173321        return  self ._callbacks .disconnect (cid )
33183322
33193323    def  message_event (self , message , sender = None ):
3320-         """ Emit a tool_message_event event """ 
3324+         """ Emit a `NavigationMessageEvent` """ 
33213325        if  sender  is  None :
33223326            sender  =  self 
33233327
@@ -3327,15 +3331,17 @@ def message_event(self, message, sender=None):
33273331
33283332    @property  
33293333    def  active_toggle (self ):
3330-         """Toggled Tool 
3334+         """ 
3335+         Toggled Tool 
33313336
33323337        **dict** :  Currently toggled tools 
33333338        """ 
33343339
33353340        return  self ._toggled 
33363341
33373342    def  get_tool_keymap (self , name ):
3338-         """Get the keymap associated with the specified tool 
3343+         """ 
3344+         Get the keymap associated with the specified tool 
33393345
33403346        Parameters 
33413347        ---------- 
@@ -3355,7 +3361,8 @@ def _remove_keys(self, name):
33553361            del  self ._keys [k ]
33563362
33573363    def  set_tool_keymap (self , name , * keys ):
3358-         """Set the keymap to associate with the specified tool 
3364+         """ 
3365+         Set the keymap to associate with the specified tool 
33593366
33603367        Parameters 
33613368        ---------- 
@@ -3365,7 +3372,7 @@ def set_tool_keymap(self, name, *keys):
33653372        """ 
33663373
33673374        if  name  not  in   self ._tools :
3368-             raise  AttributeError ('%s not in Tools'  %  name )
3375+             raise  KeyError ('%s not in Tools'  %  name )
33693376
33703377        self ._remove_keys (name )
33713378
@@ -3377,7 +3384,8 @@ def set_tool_keymap(self, name, *keys):
33773384                self ._keys [k ] =  name 
33783385
33793386    def  remove_tool (self , name ):
3380-         """Remove tool from `Navigation` 
3387+         """ 
3388+         Remove tool from `Navigation` 
33813389
33823390        Parameters 
33833391        ---------- 
@@ -3401,7 +3409,8 @@ def remove_tool(self, name):
34013409        del  self ._tools [name ]
34023410
34033411    def  add_tools (self , tools ):
3404-         """ Add multiple tools to `NavigationBase` 
3412+         """ 
3413+         Add multiple tools to `NavigationBase` 
34053414
34063415        Parameters 
34073416        ---------- 
@@ -3414,7 +3423,8 @@ def add_tools(self, tools):
34143423            self .add_tool (name , tool )
34153424
34163425    def  add_tool (self , name , tool , * args , ** kwargs ):
3417-         """Add tool to `NavigationBase` 
3426+         """ 
3427+         Add tool to `NavigationBase` 
34183428
34193429        Add a tool to the tools controlled by Navigation 
34203430
@@ -3440,11 +3450,10 @@ def add_tool(self, name, tool, *args, **kwargs):
34403450
34413451        tool_cls  =  self ._get_cls_to_instantiate (tool )
34423452        if  tool_cls  is  False :
3443-             warnings .warn ('Impossible to find class for %s'  %  str (tool ))
3444-             return 
3453+             raise  ValueError ('Impossible to find class for %s'  %  str (tool ))
34453454
34463455        if  name  in  self ._tools :
3447-             warnings .warn ('A tool_cls  with the same name already exist , ' 
3456+             warnings .warn ('A "Tool class"  with the same name already exists , ' 
34483457                          'not added' )
34493458            return  self ._tools [name ]
34503459
@@ -3454,7 +3463,7 @@ def add_tool(self, name, tool, *args, **kwargs):
34543463            self .set_tool_keymap (name , tool_cls .keymap )
34553464
34563465        # For toggle tools init the radio_group in self._toggled 
3457-         if  getattr ( tool_cls ,  'toggled' ,  False )  is   not   False :
3466+         if  isinstance ( self . _tools [ name ],  tools . ToolToggleBase ) :
34583467            # None group is not mutually exclusive, a set is used to keep track 
34593468            # of all toggled tools in this group 
34603469            if  tool_cls .radio_group  is  None :
@@ -3471,8 +3480,10 @@ def _tool_added_event(self, tool):
34713480        self ._callbacks .process (s , event )
34723481
34733482    def  _handle_toggle (self , tool , sender , canvasevent , data ):
3474-         # Toggle tools, need to untoggle prior to using other Toggle tool 
3475-         # Called from tool_trigger_event 
3483+         """ 
3484+         Toggle tools, need to untoggle prior to using other Toggle tool 
3485+         Called from tool_trigger_event 
3486+         """ 
34763487
34773488        radio_group  =  tool .radio_group 
34783489        # radio_group None is not mutually exclusive 
@@ -3522,7 +3533,8 @@ def _get_cls_to_instantiate(self, callback_class):
35223533
35233534    def  tool_trigger_event (self , name , sender = None , canvasevent = None ,
35243535                           data = None ):
3525-         """Trigger a tool and emit the tool-trigger-[name] event 
3536+         """ 
3537+         Trigger a tool and emit the tool_trigger_[name] event 
35263538
35273539        Parameters 
35283540        ---------- 
@@ -3549,7 +3561,8 @@ def tool_trigger_event(self, name, sender=None, canvasevent=None,
35493561        self ._callbacks .process (s , event )
35503562
35513563    def  _trigger_tool (self , name , sender = None , canvasevent = None , data = None ):
3552-         """Trigger on a tool 
3564+         """ 
3565+         Trigger on a tool 
35533566
35543567        Method to actually trigger the tool 
35553568        """ 
@@ -3578,7 +3591,8 @@ def tools(self):
35783591        return  self ._tools 
35793592
35803593    def  get_tool (self , name , warn = True ):
3581-         """Return the tool object, also accepts the actual tool for convenience 
3594+         """ 
3595+         Return the tool object, also accepts the actual tool for convenience 
35823596
35833597        Parameters 
35843598        ----------- 
@@ -3597,7 +3611,8 @@ def get_tool(self, name, warn=True):
35973611
35983612
35993613class  ToolContainerBase (object ):
3600-     """Base class for all tool containers, e.g. toolbars. 
3614+     """ 
3615+     Base class for all tool containers, e.g. toolbars. 
36013616
36023617     Attributes 
36033618    ---------- 
@@ -3611,14 +3626,16 @@ def __init__(self, navigation):
36113626                                    self ._remove_tool_cbk )
36123627
36133628    def  _tool_toggled_cbk (self , event ):
3614-         """Captures the 'tool-trigger-toolname 
3629+         """ 
3630+         Captures the 'tool_trigger_[name]' 
36153631
36163632        This only gets used for toggled tools 
36173633        """ 
36183634        self .toggle_toolitem (event .tool .name , event .tool .toggled )
36193635
36203636    def  add_tools (self , tools ):
3621-         """ Add multiple tools to the container. 
3637+         """ 
3638+         Add multiple tools to the container. 
36223639
36233640        Parameters 
36243641        ---------- 
@@ -3634,7 +3651,8 @@ def add_tools(self, tools):
36343651                self .add_tool (tool , group , position )
36353652
36363653    def  add_tool (self , tool , group , position = - 1 ):
3637-         """Adds a tool to this container 
3654+         """ 
3655+         Adds a tool to this container 
36383656
36393657        Parameters 
36403658        ---------- 
@@ -3670,7 +3688,8 @@ def _get_image_filename(self, image):
36703688        return  fname 
36713689
36723690    def  trigger_tool (self , name ):
3673-         """Trigger the tool 
3691+         """ 
3692+         Trigger the tool 
36743693
36753694        Parameters 
36763695        ---------- 
@@ -3681,7 +3700,8 @@ def trigger_tool(self, name):
36813700        self .navigation .tool_trigger_event (name , sender = self )
36823701
36833702    def  add_toolitem (self , name , group , position , image , description , toggle ):
3684-         """Add a toolitem to the container 
3703+         """ 
3704+         Add a toolitem to the container 
36853705
36863706        This method must get implemented per backend 
36873707
@@ -3711,7 +3731,8 @@ def add_toolitem(self, name, group, position, image, description, toggle):
37113731        raise  NotImplementedError 
37123732
37133733    def  toggle_toolitem (self , name , toggled ):
3714-         """Toggle the toolitem without firing event 
3734+         """ 
3735+         Toggle the toolitem without firing event 
37153736
37163737        Parameters 
37173738        ---------- 
@@ -3723,7 +3744,8 @@ def toggle_toolitem(self, name, toggled):
37233744        raise  NotImplementedError 
37243745
37253746    def  remove_toolitem (self , name ):
3726-         """Remove a toolitem from the `ToolContainer` 
3747+         """ 
3748+         Remove a toolitem from the `ToolContainer` 
37273749
37283750        This method must get implemented per backend 
37293751
@@ -3750,7 +3772,8 @@ def _message_cbk(self, event):
37503772        self .set_message (event .message )
37513773
37523774    def  set_message (self , s ):
3753-         """Display a message on toolbar or in status bar 
3775+         """ 
3776+         Display a message on toolbar or in status bar 
37543777
37553778        Parameters 
37563779        ---------- 
0 commit comments