8000 Shortcut for closing all figures · matplotlib/matplotlib@c3fa26f · GitHub
[go: up one dir, main page]

Skip to content

Commit c3fa26f

Browse files
committed
Shortcut for closing all figures
1 parent 72add05 commit c3fa26f

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 anymore because closing all figures by a key press
130+
might happen unintendedly too easy. 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
@@ -2329,6 +2329,7 @@ def key_press_handler(event, canvas, toolbar=None):
23292329
zoom_keys = rcParams['keymap.zoom']
23302330
save_keys = rcParams['keymap.save']
23312331
quit_keys = rcParams['keymap.quit']
2332+
quit_all_keys = rcParams['keymap.quit']
23322333
grid_keys = rcParams['keymap.grid']
23332334
grid_minor_keys = rcParams['keymap.grid_minor']
23342335
toggle_yscale_keys = rcParams['keymap.yscale']
@@ -2345,6 +2346,8 @@ def key_press_handler(event, canvas, toolbar=None):
23452346
# quit the figure (default key 'ctrl+w')
23462347
if event.key in quit_keys:
23472348
Gcf.destroy_fig(canvas.figure)
2349+
if event.key in quit_all_keys:
2350+
Gcf.destroy_all()
23482351

23492352
if toolbar is not None:
23502353
# 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)
0