Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8a65de7

Browse filesBrowse files
author
Thomas Hisch
committed
Add a quit_all key to the default keymap
1 parent caedbca commit 8a65de7
Copy full SHA for 8a65de7

File tree

Expand file treeCollapse file tree

4 files changed

+19
-2
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+19
-2
lines changed

‎doc/users/navigation_toolbar.rst

Copy file name to clipboardExpand all lines: doc/users/navigation_toolbar.rst
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ Zoom-to-rect **o**
9494
Save **ctrl** + **s**
9595
Toggle fullscreen **ctrl** + **f**
9696
Close plot **ctrl** + **w**
97-
Constrain pan/zoom to x axis hold **x** when panning/zooming with mouse
97+
Close all plots **shift** + **w**
98+
Constrain pan/zoom to x axis hold **x** when panning/zooming with mouse
9899
Constrain pan/zoom to y axis hold **y** when panning/zooming with mouse
99100
Preserve aspect ratio hold **CONTROL** when panning/zooming with mouse
100101
Toggle grid **g** when mouse is over an axes

‎lib/matplotlib/backend_bases.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backend_bases.py
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2472,6 +2472,7 @@ def key_press_handler(event, canvas, toolbar=None):
24722472
zoom_keys = rcParams['keymap.zoom']
24732473
save_keys = rcParams['keymap.save']
24742474
quit_keys = rcParams['keymap.quit']
2475+
quit_all_keys = rcParams['keymap.quit_all']
24752476
grid_keys = rcParams['keymap.grid']
24762477
toggle_yscale_keys = rcParams['keymap.yscale']
24772478
toggle_xscale_keys = rcParams['keymap.xscale']
@@ -2488,6 +2489,9 @@ def key_press_handler(event, canvas, toolbar=None):
24882489
if event.key in quit_keys:
24892490
Gcf.destroy_fig(canvas.figure)
24902491

2492+
if event.key in quit_all_keys:
2493+
Gcf.destroy_all()
2494+
24912495
if toolbar is not None:
24922496
# home or reset mnemonic (default key 'h', 'home' and 'r')
24932497
if event.key in home_keys:

‎lib/matplotlib/backend_tools.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backend_tools.py
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,16 @@ def trigger(self, sender, event, data=None):
321321
Gcf.destroy_fig(self.figure)
322322

323323

324+
class ToolQuitAll(ToolBase):
325+
"""Tool to call the figure manager destroy method"""
326+
327+
description = 'Quit all figures'
328+
default_keymap = rcParams['keymap.quit_all']
329+
330+
def trigger(self, sender, event, data=None):
331+
Gcf.destroy_all()
332+
333+
324334
class ToolEnableAllNavigation(ToolBase):
325335
"""Tool to enable all axes for toolmanager interaction"""
326336

@@ -936,6 +946,7 @@ def _mouse_move(self, event):
936946
'grid': ToolGrid,
937947
'fullscreen': ToolFullScreen,
938948
'quit': ToolQuit,
949+
'quit_all': ToolQuitAll,
939950
'allnav': ToolEnableAllNavigation,
940951
'nav': ToolEnableNavigation,
941952
'xscale': ToolXScale,

‎lib/matplotlib/rcsetup.py

Copy file name to clipboardExpand all lines: lib/matplotlib/rcsetup.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,8 @@ def __call__(self, s):
937937
'keymap.pan': [['p'], validate_stringlist],
938938
'keymap.zoom': [['o'], validate_stringlist],
939939
'keymap.save': [['s', 'ctrl+s'], validate_stringlist],
940-
'keymap.quit': [['ctrl+w', 'cmd+w'], validate_stringlist],
940+
'keymap.quit': [['ctrl+w', 'cmd+w', 'q'], validate_stringlist],
941+
'keymap.quit_all': [['W', 'cmd+W', 'Q'], validate_stringlist],
941942
'keymap.grid': [['g'], validate_stringlist],
942943
'keymap.yscale': [['l'], validate_stringlist],
943944
'keymap.xscale': [['k', 'L'], validate_stringlist],

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.