@@ -43,11 +43,11 @@ class ToolManager:
4343
4444 Attributes
4545 ----------
46- figure : `Figure`
47- keypresslock : `widgets.LockDraw`
48- `LockDraw` object to know if the `canvas` key_press_event is locked
49- messagelock : `widgets.LockDraw`
50- `LockDraw` object to know if the message is available to write
46+ figure : `. Figure`
47+ keypresslock : `~matplotlib. widgets.LockDraw`
48+ `. LockDraw` object to know if the `canvas` key_press_event is locked.
49+ messagelock : `~matplotlib. widgets.LockDraw`
50+ `. LockDraw` object to know if the message is available to write.
5151 """
5252
5353 def __init__ (self , figure = None ):
@@ -92,8 +92,8 @@ def set_figure(self, figure, update_tools=True):
9292 Parameters
9393 ----------
9494 figure : `.Figure`
95- update_tools : bool
96- Force tools to update figure
95+ update_tools : bool, default: True
96+ Force tools to update figure.
9797 """
9898 if self ._key_press_handler_id :
9999 self .canvas .mpl_disconnect (self ._key_press_handler_id )
@@ -111,23 +111,27 @@ def toolmanager_connect(self, s, func):
111111
112112 Parameters
113113 ----------
114- s : String
115- Name of the event
116-
117- The following events are recognized
114+ s : str
115+ The name of the event. The following events are recognized:
118116
119117 - 'tool_message_event'
120118 - 'tool_removed_event'
121119 - 'tool_added_event'
122120
123121 For every tool added a new event is created
124122
125- - 'tool_trigger_TOOLNAME`
126- Where TOOLNAME is the id of the tool.
123+ - 'tool_trigger_TOOLNAME', where TOOLNAME is the id of the tool.
124+
125+ func : callable
126+ Callback function for the toolmanager event with signature::
127+
128+ def func(event: ToolEvent) -> Any
127129
128- func : function
129- Function to be called with signature
130- def func(event)
130+ Returns
131+ -------
132+ cid
133+ The callback id for the connection. This can be used in
134+ `.toolmanager_disconnect`.
131135 """
132136 return self ._callbacks .connect (s , func )
133137
@@ -159,7 +163,7 @@ def active_toggle(self):
159163
160164 def get_tool_keymap (self , name ):
161165 """
162- Get the keymap associated with the specified tool.
166+ Return the keymap associated with the specified tool.
163167
164168 Parameters
165169 ----------
@@ -168,7 +172,8 @@ def get_tool_keymap(self, name):
168172
169173 Returns
170174 -------
171- list : list of keys associated with the Tool
175+ list of str
176+ List of keys associated with the tool.
172177 """
173178
174179 keys = [k for k , i in self ._keys .items () if i == name ]
@@ -186,7 +191,8 @@ def update_keymap(self, name, *keys):
186191 ----------
187192 name : str
188193 Name of the Tool.
189- keys : keys to associate with the Tool
194+ keys : list of str
195+ Keys to associate with the tool.
190196 """
191197
192198 if name not in self ._tools :
@@ -208,7 +214,7 @@ def remove_tool(self, name):
208214 Parameters
209215 ----------
210216 name : str
211- Name of the Tool .
217+ Name of the tool .
212218 """
213219
214220 tool = self .get_tool (name )
@@ -294,13 +300,13 @@ def _handle_toggle(self, tool, sender, canvasevent, data):
294300
295301 Parameters
296302 ----------
297- tool : Tool object
303+ tool : `.ToolBase`
298304 sender : object
299- Object that wishes to trigger the tool
305+ Object that wishes to trigger the tool.
300306 canvasevent : Event
301- Original Canvas event or None
302- data : Object
303- Extra data to pass to the tool when triggering
307+ Original Canvas event or None.
308+ data : object
309+ Extra data to pass to the tool when triggering.
304310 """
305311
306312 radio_group = tool .radio_group
@@ -358,11 +364,11 @@ def trigger_tool(self, name, sender=None, canvasevent=None, data=None):
358364 name : str
359365 Name of the tool.
360366 sender : object
361- Object that wishes to trigger the tool
367+ Object that wishes to trigger the tool.
362368 canvasevent : Event
363- Original Canvas event or None
364- data : Object
365- Extra data to pass to the tool when triggering
369+ Original Canvas event or None.
370+ data : object
371+ Extra data to pass to the tool when triggering.
366372 """
367373 tool = self .get_tool (name )
368374 if tool is None :
@@ -404,14 +410,22 @@ def tools(self):
404410
405411 def get_tool (self , name , warn = True ):
406412 """
407- Return the tool object, also accepts the actual tool for convenience.
413+ Return the tool object with the given name.
414+
415+ For convenience, this passes tool objects through.
408416
409417 Parameters
410418 ----------
411- name : str, ToolBase
412- Name of the tool, or the tool itself
413- warn : bool, optional
414- If this method should give warnings.
419+ name : str or `.ToolBase`
420+ Name of the tool, or the tool itself.
421+ warn : bool, default: True
422+ Whether a warning should be emitted it no tool with the given name
423+ exists.
424+
425+ Returns
426+ -------
427+ tool : `.ToolBase` or None
428+ The tool or None if no tool with the given name exists.
415429 """
416430 if isinstance (name , tools .ToolBase ) and name .name in self ._tools :
417431 return name
0 commit comments