14
14
import time
15
15
import warnings
16
16
from weakref import WeakKeyDictionary
17
-
18
17
import numpy as np
19
18
20
19
from matplotlib import rcParams
@@ -403,7 +402,7 @@ def trigger(self, sender, event, data=None):
403
402
class ToolEnableAllNavigation (ToolBase ):
404
403
"""Tool to enable all axes for toolmanager interaction"""
405
404
406
- description = 'Enables all axes toolmanager'
405
+ description = 'Enable all axes toolmanager'
407
406
default_keymap = rcParams ['keymap.all_axes' ]
408
407
409
408
def trigger (self , sender , event , data = None ):
@@ -419,7 +418,7 @@ def trigger(self, sender, event, data=None):
419
418
class ToolEnableNavigation (ToolBase ):
420
419
"""Tool to enable a specific axes for toolmanager interaction"""
421
420
422
- description = 'Enables one axes toolmanager'
421
+ description = 'Enable one axes toolmanager'
423
422
default_keymap = (1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 )
424
423
425
424
def trigger (self , sender , event , data = None ):
@@ -470,7 +469,7 @@ def _get_uniform_grid_state(ticks):
470
469
class ToolGrid (_ToolGridBase ):
471
470
"""Tool to toggle the major grids of the figure"""
472
471
473
- description = 'Toogle major grids'
472
+ description = 'Toggle major grids'
474
473
default_keymap = rcParams ['keymap.grid' ]
475
474
476
475
def _get_next_grid_states (self , ax ):
@@ -491,7 +490,7 @@ def _get_next_grid_states(self, ax):
491
490
class ToolMinorGrid (_ToolGridBase ):
492
491
"""Tool to toggle the major and minor grids of the figure"""
493
492
494
- description = 'Toogle major and minor grids'
493
+ description = 'Toggle major and minor grids'
495
494
default_keymap = rcParams ['keymap.grid_minor' ]
496
495
497
496
def _get_next_grid_states (self , ax ):
@@ -511,7 +510,7 @@ def _get_next_grid_states(self, ax):
511
510
class ToolFullScreen (ToolToggleBase ):
512
511
"""Tool to toggle full screen"""
513
512
514
- description = 'Toogle Fullscreen mode'
513
+ description = 'Toggle fullscreen mode'
515
514
default_keymap = rcParams ['keymap.fullscreen' ]
516
515
517
516
def enable (self , event ):
@@ -541,7 +540,7 @@ def disable(self, event):
541
540
class ToolYScale (AxisScaleBase ):
542
541
"""Tool to toggle between linear and logarithmic scales on the Y axis"""
543
542
544
- description = 'Toogle Scale Y axis'
543
+ description = 'Toggle scale Y axis'
545
544
default_keymap = rcParams ['keymap.yscale' ]
546
545
547
546
def set_scale (self , ax , scale ):
@@ -551,7 +550,7 @@ def set_scale(self, ax, scale):
551
550
class ToolXScale (AxisScaleBase ):
552
551
"""Tool to toggle between linear and logarithmic scales on the X axis"""
553
552
554
- description = 'Toogle Scale X axis'
553
+ description = 'Toggle scale X axis'
555
554
default_keymap = rcParams ['keymap.xscale' ]
556
555
557
556
def set_scale (self , ax , scale ):
@@ -1020,6 +1019,35 @@ def _mouse_move(self, event):
1020
1019
self .toolmanager .canvas .draw_idle ()
1021
1020
1022
1021
1022
+ class ToolHelpBase (ToolBase ):
1023
+ description = 'Print tool list, shortcuts and description'
1024
+ default_keymap = rcParams ['keymap.help' ]
1025
+ image = 'help.png'
1026
+
1027
+ def _get_help_text (self ):
1028
+ entries = []
1029
+ for name , tool in sorted (self .toolmanager .tools .items ()):
1030
+ if not tool .description :
1031
+ continue
1032
+ entries .append (
1033
+ "{}: {}\n \t {}" .format (
1034
+ name ,
1035
+ ", " .join (self .toolmanager .get_tool_keymap (name )),
1036
+ tool .description ))
1037
+ return "\n " .join (entries )
1038
+
1039
+ def _get_help_html (self ):
1040
+ fmt = "<tr><td>{}</td><td>{}</td><td>{}</td></tr>"
1041
+ rows = [fmt .format ("<b>Name</b>" , "<b>Keys</b>" , "<b>Description</b>" )]
1042
+ for name , tool in sorted (self .toolmanager .tools .items ()):
1043
+ if not tool .description :
1044
+ continue
1045
+ keys = ", " .join (self .toolmanager .get_tool_keymap (name ))
1046
+ rows .append (fmt .format (name , keys , tool .description ))
1047
+ return ("<table><thead>" + rows [0 ] + "</thead>"
1048
+ "<tbody>" .join (rows [1 :]) + "</tbody></table>" )
1049
+
1050
+
1023
1051
default_tools = {'home' : ToolHome , 'back' : ToolBack , 'forward' : ToolForward ,
1024
1052
'zoom' : ToolZoom , 'pan' : ToolPan ,
1025
1053
'subplots' : 'ToolConfigureSubplots' ,
@@ -1037,12 +1065,13 @@ def _mouse_move(self, event):
1037
1065
_views_positions : ToolViewsPositions ,
1038
1066
'cursor' : 'ToolSetCursor' ,
1039
1067
'rubberband' : 'ToolRubberband' ,
1068
+ 'help' : 'ToolHelp' ,
1040
1069
}
1041
1070
"""Default tools"""
1042
1071
1043
1072
default_toolbar_tools = [['navigation' , ['home' , 'back' , 'forward' ]],
1044
1073
['zoompan' , ['pan' , 'zoom' , 'subplots' ]],
1045
- ['io' , ['save' ]]]
1074
+ ['io' , ['save' , 'help' ]]]
1046
1075
"""Default tools in the toolbar"""
1047
1076
1048
1077
0 commit comments