Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9eaae32

Browse files
committed
Clean up and add more docs
1 parent 87ab199 commit 9eaae32

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

lib/matplotlib/widgets.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ def __init__(self, ax, onselect, useblit=False, button=None,
11451145
self.connect_default_events()
11461146

11471147
self.state_modifier_keys = dict(move=' ', clear='escape',
1148-
square='shift', center='ctrl')
1148+
square='shift', center='control')
11491149
self.state_modifier_keys.update(state_modifier_keys or {})
11501150

11511151
self.background = None
@@ -1273,7 +1273,8 @@ def press(self, event):
12731273
self.eventpress = event
12741274
self._prev_event = event
12751275
key = event.key or ''
1276-
key = key.replace('control', 'ctrl')
1276+
key = key.replace('ctrl', 'control')
1277+
# move state is locked in on a button press
12771278
if key == self.state_modifier_keys['move']:
12781279
self.state.add('move')
12791280
self._press(event)
@@ -1322,10 +1323,10 @@ def _on_scroll(self, event):
13221323
pass
13231324

13241325
def on_key_press(self, event):
1325-
"""Key press event handler and validator"""
1326+
"""Key press event handler and validator for all selection widgets"""
13261327
if self.active:
13271328
key = event.key or ''
1328-
key = key.replace('control', 'ctrl')
1329+
key = key.replace('ctrl', 'control')
13291330
if key == self.state_modifier_keys['clear']:
13301331
for artist in self.artists:
13311332
artist.set_visible(False)
@@ -1337,7 +1338,8 @@ def on_key_press(self, event):
13371338
self._on_key_press(event)
13381339

13391340
def _on_key_press(self, event):
1340-
"""Key press event handler"""
1341+
"""Key press event handler - use for widget-specific key press actions.
1342+
"""
13411343
pass
13421344

13431345
def on_key_release(self, event):
@@ -1424,7 +1426,7 @@ def __init__(self, ax, onselect, direction, minspan=None, useblit=False,
14241426
if rectprops is None:
14251427
rectprops = dict(facecolor='red', alpha=0.5)
14261428

1427-
rectprops['animated'] = useblit
1429+
rectprops['animated'] = self.useblit
14281430

14291431
if direction not in ['horizontal', 'vertical']:
14301432
msg = "direction must be in [ 'horizontal' | 'vertical' ]"
@@ -1567,7 +1569,6 @@ def _onmove(self, event):
15671569

15681570

15691571
class ToolHandles(object):
1570-
15711572
"""Control handles for canvas tools.
15721573
15731574
Parameters

0 commit comments

Comments
 (0)