@@ -1571,13 +1571,21 @@ def __init__(self, figure):
15711571 self .scroll_pick_id = self .mpl_connect ('scroll_event' , self .pick )
15721572 self .mouse_grabber = None # the axes currently grabbing mouse
15731573 self .toolbar = None # NavigationToolbar2 will set me
1574+ self ._is_saving = False
15741575 if False :
15751576 ## highlight the artists that are hit
15761577 self .mpl_connect ('motion_notify_event' , self .onHilite )
15771578 ## delete the artists that are clicked on
15781579 #self.mpl_disconnect(self.button_pick_id)
15791580 #self.mpl_connect('button_press_event',self.onRemove)
15801581
1582+ def is_saving (self ):
1583+ """
1584+ Returns `True` when the renderer is in the process of saving
1585+ to a file, rather than rendering for an on-screen buffer.
1586+ """
1587+ return self ._is_saving
1588+
15811589 def onRemove (self , ev ):
15821590 """
15831591 Mouse event processor which removes the top artist
@@ -2205,6 +2213,7 @@ def print_figure(self, filename, dpi=None, facecolor='w', edgecolor='w',
22052213 else :
22062214 _bbox_inches_restore = None
22072215
2216+ self ._is_saving = True
22082217 try :
22092218 #result = getattr(self, method_name)(
22102219 result = print_method (
@@ -2223,6 +2232,7 @@ def print_figure(self, filename, dpi=None, facecolor='w', edgecolor='w',
22232232 self .figure .set_facecolor (origfacecolor )
22242233 self .figure .set_edgecolor (origedgecolor )
22252234 self .figure .set_canvas (self )
2235+ self ._is_saving = False
22262236 #self.figure.canvas.draw() ## seems superfluous
22272237 return result
22282238
@@ -2269,6 +2279,7 @@ def switch_backends(self, FigureCanvasClass):
22692279 figure size or line props), will be reflected in the other
22702280 """
22712281 newCanvas = FigureCanvasClass (self .figure )
2282+ newCanvas ._is_saving = self ._is_saving
22722283 return newCanvas
22732284
22742285 def mpl_connect (self , s , func ):
0 commit comments