File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2882,6 +2882,9 @@ def destroy(self):
28822882 def full_screen_toggle (self ):
28832883 pass
28842884
2885+ def raise_window (self ):
2886+ """For GUI backends, raise the figure window to the top."""
2887+
28852888 def resize (self , w , h ):
28862889 """For GUI backends, resize the window (in physical pixels)."""
28872890
Original file line number Diff line number Diff line change @@ -221,15 +221,19 @@ def show(self):
221221 self .window .show ()
222222 self .canvas .draw ()
223223 if mpl .rcParams ["figure.raise_window" ]:
224- meth_name = {3 : "get_window" , 4 : "get_surface" }[self ._gtk_ver ]
225- if getattr (self .window , meth_name )():
226- self .window .present ()
227- else :
228- # If this is called by a callback early during init,
229- # self.window (a GtkWindow) may not have an associated
230- # low-level GdkWindow (on GTK3) or GdkSurface (on GTK4) yet,
231- # and present() would crash.
232- _api .warn_external ("Cannot raise window yet to be setup" )
224+ self .raise_window ()
225+
226+ def raise_window (self ):
227+ # docstring inherited
228+ meth_name = {3 : "get_window" , 4 : "get_surface" }[self ._gtk_ver ]
229+ if getattr (self .window , meth_name )():
230+ self .window .present ()
231+ else :
232+ # If this is called by a callback early during init,
233+ # self.window (a GtkWindow) may not have an associated
234+ # low-level GdkWindow (on GTK3) or GdkSurface (on GTK4) yet,
235+ # and present() would crash.
236+ _api .warn_external ("Cannot raise window yet to be setup" )
233237
234238 def full_screen_toggle (self ):
235239 is_fullscreen = {
Original file line number Diff line number Diff line change @@ -615,10 +615,14 @@ def destroy(*args):
615615 else :
616616 self .canvas .draw_idle ()
617617 if mpl .rcParams ['figure.raise_window' ]:
618- self .canvas .manager .window .attributes ('-topmost' , 1 )
619- self .canvas .manager .window .attributes ('-topmost' , 0 )
618+ self .raise_window ()
620619 self ._shown = True
621620
621+ def raise_window (self ):
622+ # docstring inherited
623+ self .window .attributes ('-topmost' , 1 )
624+ self .window .attributes ('-topmost' , 0 )
625+
622626 def destroy (self , * args ):
623627 if self .canvas ._idle_draw_id :
624628 self .canvas ._tkcanvas .after_cancel (self .canvas ._idle_draw_id )
Original file line number Diff line number Diff line change @@ -186,7 +186,11 @@ def show(self):
186186 self ._show ()
187187 self ._shown = True
188188 if mpl .rcParams ["figure.raise_window" ]:
189- self ._raise ()
189+ self .raise_window ()
190+
191+ def raise_window (self ):
192+ # docstring inherited
193+ self ._raise ()
190194
191195
192196@_Backend .export
Original file line number Diff line number Diff line change @@ -664,8 +664,12 @@ def show(self):
664664 self .window ._destroying = False
665665 self .window .show ()
666666 if mpl .rcParams ['figure.raise_window' ]:
667- self .window .activateWindow ()
668- self .window .raise_ ()
667+ self .raise_window ()
668+
669+ def raise_window (self ):
670+ # docstring inherited
671+ self .window .activateWindow ()
672+ self .window .raise_ ()
669673
670674 def destroy (self , * args ):
671675 # check for qApp first, as PySide deletes it in its atexit handler
Original file line number Diff line number Diff line change @@ -1002,7 +1002,11 @@ def show(self):
10021002 self .frame .Show ()
10031003 self .canvas .draw ()
10041004 if mpl .rcParams ['figure.raise_window' ]:
1005- self .frame .Raise ()
1005+ self .raise_window ()
1006+
1007+ def raise_window (self ):
1008+ # docstring inherited
1009+ self .frame .Raise ()
10061010
10071011 def destroy (self , * args ):
10081012 # docstring inherited
You can’t perform that action at this time.
0 commit comments