From 1b4c4ad304509a669f2ff9c44ff47c4d43bcf3c4 Mon Sep 17 00:00:00 2001 From: Max Chen Date: Fri, 18 Oct 2019 23:37:32 +0800 Subject: [PATCH 1/2] Use rcParams to control default "raise window" behavior #8692 (Qt,Gtk,Tk,Wx) A new rcParms entry have been added: "figure.raise_window" Now it is possible to disable the default "raise GUI window" behavior This change apply to & tested on Qt, Gtk, Tk and Wx backends (CentOS7 & Win7) Has document it in the 'whats new' section --- .../2019-10-18_rcParams-for-raise-window-behavior.rst | 7 +++++++ lib/matplotlib/backends/_backend_tk.py | 6 +++--- lib/matplotlib/backends/backend_gtk3.py | 4 +++- lib/matplotlib/backends/backend_qt5.py | 5 +++-- lib/matplotlib/backends/backend_wx.py | 2 ++ lib/matplotlib/rcsetup.py | 1 + lib/matplotlib/style/core.py | 3 ++- matplotlibrc.template | 1 + 8 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 doc/users/next_whats_new/2019-10-18_rcParams-for-raise-window-behavior.rst 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..22a15684caff --- /dev/null +++ b/doc/users/next_whats_new/2019-10-18_rcParams-for-raise-window-behavior.rst @@ -0,0 +1,7 @@ +: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. + 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 From 1c35ef026737fb4a62e5260d707f0735c6d39b4f Mon Sep 17 00:00:00 2001 From: Max Chen Date: Tue, 28 Jan 2020 22:58:09 +0800 Subject: [PATCH 2/2] adding a note about OSX not being supported --- .../2019-10-18_rcParams-for-raise-window-behavior.rst | 1 + 1 file changed, 1 insertion(+) 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 index 22a15684caff..017e1493a9c8 100644 --- 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 @@ -4,4 +4,5 @@ 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. pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy