@@ -1485,13 +1485,21 @@ def __init__(self, figure):
1485
1485
self .scroll_pick_id = self .mpl_connect ('scroll_event' ,self .pick )
1486
1486
self .mouse_grabber = None # the axes currently grabbing mouse
1487
1487
self .toolbar = None # NavigationToolbar2 will set me
1488
+ self ._is_saving = False
1488
1489
if False :
1489
1490
## highlight the artists that are hit
1490
1491
self .mpl_connect ('motion_notify_event' ,self .onHilite )
1491
1492
## delete the artists that are clicked on
1492
1493
#self.mpl_disconnect(self.button_pick_id)
1493
1494
#self.mpl_connect('button_press_event',self.onRemove)
1494
1495
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
+
1495
1503
def onRemove (self , ev ):
1496
1504
"""
1497
1505
Mouse event processor which removes the top artist
@@ -2096,6 +2104,7 @@ def print_figure(self, filename, dpi=None, facecolor='w', edgecolor='w',
2096
2104
else :
2097
2105
_bbox_inches_restore = None
2098
2106
2107
+ self ._is_saving = True
2099
2108
try :
2100
2109
#result = getattr(self, method_name)(
2101
2110
result = print_method (
@@ -2114,6 +2123,7 @@ def print_figure(self, filename, dpi=None, facecolor='w', edgecolor='w',
2114
2123
self .figure .set_facecolor (origfacecolor )
2115
2124
self .figure .set_edgecolor (origedgecolor )
2116
2125
self .figure .set_canvas (self )
2126
+ self ._is_saving = False
2117
2127
#self.figure.canvas.draw() ## seems superfluous
2118
2128
return result
2119
2129
@@ -2160,6 +2170,7 @@ def switch_backends(self, FigureCanvasClass):
2160
2170
figure size or line props), will be reflected in the other
2161
2171
"""
2162
2172
newCanvas = FigureCanvasClass (self .figure )
2173
+ newCanvas ._is_saving = self ._is_saving
2163
2174
return newCanvas
2164
2175
2165
2176
def mpl_connect (self , s , func ):
0 commit comments