Skip to content

Commit 1b4c4ad

Browse files
committed
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
1 parent ea79c2a commit 1b4c4ad

File tree

8 files changed

+22
-7
lines changed

8 files changed

+22
-7
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
:orphan:
2+
3+
rcParams for controlling default "raise window" behavior
4+
--------------------------------------------------------
5+
The new config option ``rcParams['figure.raise_window']`` allows to disable
6+
raising the plot window when calling ``plt.show`` or ``plt.pause`` methods.
7+

lib/matplotlib/backends/_backend_tk.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,9 @@ def destroy(*args):
475475
self.window.deiconify()
476476
else:
477477
self.canvas.draw_idle()
478-
# Raise the new window.
479-
self.canvas.manager.window.attributes('-topmost', 1)
480-
self.canvas.manager.window.attributes('-topmost', 0)
478+
if matplotlib.rcParams['figure.raise_window']:
479+
self.canvas.manager.window.attributes('-topmost', 1)
480+
self.canvas.manager.window.attributes('-topmost', 0)
481481
self._shown = True
482482

483483
def destroy(self, *args):

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,9 @@ def destroy(self, *args):
411411
def show(self):
412412
# show the figure window
413413
self.window.show()
414-
self.window.present()
414+
self.canvas.draw()
415+
if matplotlib.rcParams['figure.raise_window']:
416+
self.window.present()
415417

416418
def full_screen_toggle(self):
417419
self._full_screen_flag = not self._full_screen_flag

lib/matplotlib/backends/backend_qt5.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -628,8 +628,9 @@ def resize(self, width, height):
628628

629629
def show(self):
630630
self.window.show()
631-
self.window.activateWindow()
632-
self.window.raise_()
631+
if matplotlib.rcParams['figure.raise_window']:
632+
self.window.activateWindow()
633+
self.window.raise_()
633634

634635
def destroy(self, *args):
635636
# check for qApp first, as PySide deletes it in its atexit handler

lib/matplotlib/backends/backend_wx.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,8 @@ def __init__(self, canvas, num, frame):
11391139
def show(self):
11401140
self.frame.Show()
11411141
self.canvas.draw()
1142+
if matplotlib.rcParams['figure.raise_window']:
1143+
self.frame.Raise()
11421144

11431145
def destroy(self, *args):
11441146
_log.debug("%s - destroy()", type(self))

lib/matplotlib/rcsetup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,6 +1348,7 @@ def _validate_linestyle(ls):
13481348
'figure.frameon': [True, validate_bool],
13491349
'figure.autolayout': [False, validate_bool],
13501350
'figure.max_open_warning': [20, validate_int],
1351+
'figure.raise_window': [True, validate_bool],
13511352

13521353
'figure.subplot.left': [0.125, _range_validators["0 <= x <= 1"]],
13531354
'figure.subplot.right': [0.9, _range_validators["0 <= x <= 1"]],

lib/matplotlib/style/core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
'interactive', 'backend', 'backend.qt4', 'webagg.port', 'webagg.address',
3939
'webagg.port_retries', 'webagg.open_in_browser', 'backend_fallback',
4040
'toolbar', 'timezone', 'datapath', 'figure.max_open_warning',
41-
'savefig.directory', 'tk.window_focus', 'docstring.hardcopy'}
41+
'figure.raise_window', 'savefig.directory', 'tk.window_focus',
42+
'docstring.hardcopy'}
4243

4344

4445
def _remove_blacklisted_style_params(d, warn=True):

matplotlibrc.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,7 @@
533533
#figure.max_open_warning : 20 ## The maximum number of figures to open through
534534
## the pyplot interface before emitting a warning.
535535
## If less than one this feature is disabled.
536+
#figure.raise_window : True ## Raise the GUI window to front when show() is called
536537

537538
## The figure subplot parameters. All dimensions are a fraction of the figure width and height.
538539
#figure.subplot.left : 0.125 ## the left side of the subplots of the figure

0 commit comments

Comments
 (0)