@@ -1485,13 +1485,21 @@ def __init__(self, figure):
14851485 self .scroll_pick_id = self .mpl_connect ('scroll_event' ,self .pick )
14861486 self .mouse_grabber = None # the axes currently grabbing mouse
14871487 self .toolbar = None # NavigationToolbar2 will set me
1488+ self ._is_saving = False
14881489 if False :
14891490 ## highlight the artists that are hit
14901491 self .mpl_connect ('motion_notify_event' ,self .onHilite )
14911492 ## delete the artists that are clicked on
14921493 #self.mpl_disconnect(self.button_pick_id)
14931494 #self.mpl_connect('button_press_event',self.onRemove)
14941495
1496+ def is_saving (self ):
1497+ """
1498+ Returns `True` when the renderer is in the process of saving
1499+ to a file, rather than rendering for an on-screen buffer.
1500+ """
1501+ return self ._is_saving
1502+
14951503 def onRemove (self , ev ):
14961504 """
14971505 Mouse event processor which removes the top artist
@@ -2096,6 +2104,7 @@ def print_figure(self, filename, dpi=None, facecolor='w', edgecolor='w',
20962104 else :
20972105 _bbox_inches_restore = None
20982106
2107+ self ._is_saving = True
20992108 try :
21002109 #result = getattr(self, method_name)(
21012110 result = print_method (
@@ -2114,6 +2123,7 @@ def print_figure(self, filename, dpi=None, facecolor='w', edgecolor='w',
21142123 self .figure .set_facecolor (origfacecolor )
21152124 self .figure .set_edgecolor (origedgecolor )
21162125 self .figure .set_canvas (self )
2126+ self ._is_saving = False
21172127 #self.figure.canvas.draw() ## seems superfluous
21182128 return result
21192129
@@ -2160,6 +2170,7 @@ def switch_backends(self, FigureCanvasClass):
21602170 figure size or line props), will be reflected in the other
21612171 """
21622172 newCanvas = FigureCanvasClass (self .figure )
2173+ newCanvas ._is_saving = self ._is_saving
21632174 return newCanvas
21642175
21652176 def mpl_connect (self , s , func ):
0 commit comments