Skip to content

Commit 3e6c5d0

Browse files
authored
Merge pull request #16863 from timhoffm/quit-all2
Shortcut for closing all figures
2 parents cf4021a + 40da397 commit 3e6c5d0

File tree

5 files changed

+13
-3
lines changed

5 files changed

+13
-3
lines changed

doc/api/next_api_changes/behaviour.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,10 @@ This behavior is consistent with other figure saving methods
122122
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
123123
This is consistent with other signature mismatch errors. Previously a
124124
ValueError was raised.
125+
126+
Shortcut for closing all figures
127+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
128+
Shortcuts for closing all figures now also work for the classic toolbar.
129+
There is no default shortcut any more because unintentionally closing all figures by a key press
130+
might happen too easily. You can configure the shortcut yourself
131+
using :rc:`keymap.quit_all`.

doc/users/navigation_toolbar.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Zoom-to-rect **o**
9494
Save **ctrl** + **s**
9595
Toggle fullscreen **f** or **ctrl** + **f**
9696
Close plot **ctrl** + **w**
97-
Close all plots **shift** + **w**
97+
Close all plots *unassigned*
9898
Constrain pan/zoom to x axis hold **x** when panning/zooming with mouse
9999
Constrain pan/zoom to y axis hold **y** when panning/zooming with mouse
100100
Preserve aspect ratio hold **CONTROL** when panning/zooming with mouse

lib/matplotlib/backend_bases.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2333,6 +2333,7 @@ def key_press_handler(event, canvas, toolbar=None):
23332333
zoom_keys = rcParams['keymap.zoom']
23342334
save_keys = rcParams['keymap.save']
23352335
quit_keys = rcParams['keymap.quit']
2336+
quit_all_keys = rcParams['keymap.quit']
23362337
grid_keys = rcParams['keymap.grid']
23372338
grid_minor_keys = rcParams['keymap.grid_minor']
23382339
toggle_yscale_keys = rcParams['keymap.yscale']
@@ -2349,6 +2350,8 @@ def key_press_handler(event, canvas, toolbar=None):
23492350
# quit the figure (default key 'ctrl+w')
23502351
if event.key in quit_keys:
23512352
Gcf.destroy_fig(canvas.figure)
2353+
if event.key in quit_all_keys:
2354+
Gcf.destroy_all()
23522355

23532356
if toolbar is not None:
23542357
# home or reset mnemonic (default key 'h', 'home' and 'r')

lib/matplotlib/rcsetup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ def _convert_validator_spec(key, conv):
14621462
'keymap.zoom': [['o'], validate_stringlist],
14631463
'keymap.save': [['s', 'ctrl+s'], validate_stringlist],
14641464
'keymap.quit': [['ctrl+w', 'cmd+w', 'q'], validate_stringlist],
1465-
'keymap.quit_all': [['W', 'cmd+W', 'Q'], validate_stringlist],
1465+
'keymap.quit_all': [[], validate_stringlist], # proposed values: 'W', 'cmd+W', 'Q'
14661466
'keymap.grid': [['g'], validate_stringlist],
14671467
'keymap.grid_minor': [['G'], validate_stringlist],
14681468
'keymap.yscale': [['l'], validate_stringlist],

matplotlibrc.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@
708708
#keymap.save: s, ctrl+s # saving current figure
709709
#keymap.help: f1 # display help about active tools
710710
#keymap.quit: ctrl+w, cmd+w, q # close the current figure
711-
#keymap.quit_all: W, cmd+W, Q # close all figures
711+
#keymap.quit_all: # close all figures
712712
#keymap.grid: g # switching on/off major grids in current axes
713713
#keymap.grid_minor: G # switching on/off minor grids in current axes
714714
#keymap.yscale: l # toggle scaling of y-axes ('log'/'linear')

0 commit comments

Comments
 (0)