diff --git a/doc/users/next_whats_new/2019-10-18_rcParams-for-raise-window-behavior.rst b/doc/users/next_whats_new/2019-10-18_rcParams-for-raise-window-behavior.rst new file mode 100644 index 000000000000..017e1493a9c8 --- /dev/null +++ b/doc/users/next_whats_new/2019-10-18_rcParams-for-raise-window-behavior.rst @@ -0,0 +1,8 @@ +:orphan: + +rcParams for controlling default "raise window" behavior +-------------------------------------------------------- +The new config option ``rcParams['figure.raise_window']`` allows to disable +raising the plot window when calling ``plt.show`` or ``plt.pause`` methods. +``MacOSX`` backend is currently not supported. + diff --git a/lib/matplotlib/backends/_backend_tk.py b/lib/matplotlib/backends/_backend_tk.py index c5b12e002006..8ae6cb5630f0 100644 --- a/lib/matplotlib/backends/_backend_tk.py +++ b/lib/matplotlib/backends/_backend_tk.py @@ -475,9 +475,9 @@ def destroy(*args): self.window.deiconify() else: self.canvas.draw_idle() - # Raise the new window. - self.canvas.manager.window.attributes('-topmost', 1) - self.canvas.manager.window.attributes('-topmost', 0) + if matplotlib.rcParams['figure.raise_window']: + self.canvas.manager.window.attributes('-topmost', 1) + self.canvas.manager.window.attributes('-topmost', 0) self._shown = True def destroy(self, *args): diff --git a/lib/matplotlib/backends/backend_gtk3.py b/lib/matplotlib/backends/backend_gtk3.py index 7b835b86e8fa..8e64490722c5 100644 --- a/lib/matplotlib/backends/backend_gtk3.py +++ b/lib/matplotlib/backends/backend_gtk3.py @@ -411,7 +411,9 @@ def destroy(self, *args): def show(self): # show the figure window self.window.show() - self.window.present() + self.canvas.draw() + if matplotlib.rcParams['figure.raise_window']: + self.window.present() def full_screen_toggle(self): self._full_screen_flag = not self._full_screen_flag diff --git a/lib/matplotlib/backends/backend_qt5.py b/lib/matplotlib/backends/backend_qt5.py index d280f7fc1bc9..3ed8d25eafaa 100644 --- a/lib/matplotlib/backends/backend_qt5.py +++ b/lib/matplotlib/backends/backend_qt5.py @@ -628,8 +628,9 @@ def resize(self, width, height): def show(self): self.window.show() - self.window.activateWindow() - self.window.raise_() + if matplotlib.rcParams['figure.raise_window']: + self.window.activateWindow() + self.window.raise_() def destroy(self, *args): # check for qApp first, as PySide deletes it in its atexit handler diff --git a/lib/matplotlib/backends/backend_wx.py b/lib/matplotlib/backends/backend_wx.py index 4cc683085833..da52ed3cdabd 100644 --- a/lib/matplotlib/backends/backend_wx.py +++ b/lib/matplotlib/backends/backend_wx.py @@ -1139,6 +1139,8 @@ def __init__(self, canvas, num, frame): def show(self): self.frame.Show() self.canvas.draw() + if matplotlib.rcParams['figure.raise_window']: + self.frame.Raise() def destroy(self, *args): _log.debug("%s - destroy()", type(self)) diff --git a/lib/matplotlib/rcsetup.py b/lib/matplotlib/rcsetup.py index d0cd93552c56..05270da7f7fc 100644 --- a/lib/matplotlib/rcsetup.py +++ b/lib/matplotlib/rcsetup.py @@ -1348,6 +1348,7 @@ def _validate_linestyle(ls): 'figure.frameon': [True, validate_bool], 'figure.autolayout': [False, validate_bool], 'figure.max_open_warning': [20, validate_int], + 'figure.raise_window': [True, validate_bool], 'figure.subplot.left': [0.125, _range_validators["0 <= x <= 1"]], 'figure.subplot.right': [0.9, _range_validators["0 <= x <= 1"]], diff --git a/lib/matplotlib/style/core.py b/lib/matplotlib/style/core.py index 577c9f51e7a5..2ea1092b57cf 100644 --- a/lib/matplotlib/style/core.py +++ b/lib/matplotlib/style/core.py @@ -38,7 +38,8 @@ 'interactive', 'backend', 'backend.qt4', 'webagg.port', 'webagg.address', 'webagg.port_retries', 'webagg.open_in_browser', 'backend_fallback', 'toolbar', 'timezone', 'datapath', 'figure.max_open_warning', - 'savefig.directory', 'tk.window_focus', 'docstring.hardcopy'} + 'figure.raise_window', 'savefig.directory', 'tk.window_focus', + 'docstring.hardcopy'} def _remove_blacklisted_style_params(d, warn=True): diff --git a/matplotlibrc.template b/matplotlibrc.template index 17f12a673ebc..57f3cc75c782 100644 --- a/matplotlibrc.template +++ b/matplotlibrc.template @@ -533,6 +533,7 @@ #figure.max_open_warning : 20 ## The maximum number of figures to open through ## the pyplot interface before emitting a warning. ## If less than one this feature is disabled. +#figure.raise_window : True ## Raise the GUI window to front when show() is called ## The figure subplot parameters. All dimensions are a fraction of the figure width and height. #figure.subplot.left : 0.125 ## the left side of the subplots of the figure
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: