@@ -231,7 +231,7 @@ def __init__(self, ax, label, image=None,
231
231
horizontalalignment = 'center' ,
232
232
transform = ax .transAxes )
233
233
234
- self ._useblit = useblit and self . canvas . supports_blit
234
+ self ._useblit = useblit
235
235
236
236
self ._observers = cbook .CallbackRegistry (signals = ["clicked" ])
237
237
@@ -265,7 +265,7 @@ def _motion(self, event):
265
265
if not colors .same_color (c ,self .ax .get_facecolor ()):
266
266
self .ax .set_facecolor (c )
267
267
if self .drawon :
268
- if self ._useblit :
268
+ if self ._useblit and self . canvas . supports_blit :
269
269
self .ax .draw_artist (self .ax )
270
270
self .canvas .blit (self .ax .bbox )
271
271
else :
@@ -1087,7 +1087,7 @@ def __init__(self, ax, labels, actives=None, *, useblit=True,
1087
1087
if actives is None :
1088
1088
actives = [False ]* len (labels )
1089
1089
1090
- self ._useblit = useblit and self .canvas .supports_blit
1090
+ self ._useblit = useblit and self .canvas .supports_blit # TODO: make dynamic
1091
1091
1092
1092
ys = np .linspace (1 ,0 ,len (labels )+ 2 )[1 :- 1 ]
1093
1093
@@ -1674,7 +1674,7 @@ def __init__(self, ax, labels, active=0, activecolor=None, *,
1674
1674
1675
1675
ys = np .linspace (1 ,0 ,len (labels )+ 2 )[1 :- 1 ]
1676
1676
1677
- self ._useblit = useblit and self .canvas .supports_blit
1677
+ self ._useblit = useblit and self .canvas .supports_blit # TODO: make dynamic
1678
1678
1679
1679
label_props = _expand_text_props (label_props )
1680
1680
self .labels = [
@@ -1960,7 +1960,7 @@ def __init__(self, ax, *, horizOn=True, vertOn=True, useblit=False,
1960
1960
self .visible = True
1961
1961
self .horizOn = horizOn
1962
1962
self .vertOn = vertOn
1963
- self .useblit = useblit and self .canvas .supports_blit
1963
+ self .useblit = useblit and self .canvas .supports_blit # TODO: make dynamic
1964
1964
1965
1965
if self .useblit :
1966
1966
lineprops ['animated' ]= True
@@ -2069,6 +2069,7 @@ def __init__(self, canvas, axes, *, useblit=True, horizOn=False, vertOn=True,
2069
2069
self .useblit = (
2070
2070
useblit
2071
2071
and all (canvas .supports_blit for canvas in self ._canvas_infos ))
2072
+ # TODO: make dynamic
2072
2073
2073
2074
if self .useblit :
2074
2075
lineprops ['animated' ]= True
@@ -2153,7 +2154,7 @@ def __init__(self, ax, onselect=None, useblit=False, button=None,
2153
2154
self .onselect = lambda * args :None
2154
2155
else :
2155
2156
self .onselect = onselect
2156
- self .useblit = useblit and self . canvas . supports_blit
2157
+ self ._useblit = useblit
2157
2158
self .connect_default_events ()
2158
2159
2159
2160
self ._state_modifier_keys = dict (move = ' ' ,clear = 'escape' ,
@@ -2177,6 +2178,11 @@ def __init__(self, ax, onselect=None, useblit=False, button=None,
2177
2178
self ._prev_event = None
2178
2179
self ._state = set ()
2179
2180
2181
+ @property
2182
+ def useblit (self ):
2183
+ """Return whether blitting is used (requested and supported by canvas)."""
2184
+ return self ._useblit and self .canvas .supports_blit
2185
+
2180
2186
def set_active (self ,active ):
2181
2187
super ().set_active (active )
2182
2188
if active :
@@ -2599,7 +2605,14 @@ def __init__(self, ax, onselect, direction, *, minspan=0, useblit=False,
2599
2605
if props is None :
2600
2606
props = dict (facecolor = 'red' ,alpha = 0.5 )
2601
2607
2602
- props ['animated' ]= self .useblit
2608
+ # Note: We set this based on the user setting during ínitialization,
2609
+ # not on the actual capability of blitting. But the value is
2610
+ # irrelevant if the backend does not support blitting, so that
2611
+ # we don't have to dynamically update this on the backend.
2612
+ # This relies on the current behavior that the request for
2613
+ # useblit is fixed during initialization and cannot be changed
2614
+ # afterwards.
2615
+ props ['animated' ]= self ._useblit
2603
2616
2604
2617
self .direction = direction
2605
2618
self ._extents_on_press = None
@@ -2665,7 +2678,7 @@ def _setup_edge_handles(self, props):
2665
2678
self ._edge_handles = ToolLineHandles (self .ax ,positions ,
2666
2679
direction = self .direction ,
2667
2680
line_props = props ,
2668
- useblit = self .useblit )
2681
+ useblit = self ._useblit )
2669
2682
2670
2683
@property
2671
2684
def _handles_artists (self ):
@@ -3239,7 +3252,7 @@ def __init__(self, ax, onselect=None, *, minspanx=0,
3239
3252
if props is None :
3240
3253
props = dict (facecolor = 'red' ,edgecolor = 'black' ,
3241
3254
alpha = 0.2 ,fill = True )
3242
- props = {** props ,'animated' :self .useblit }
3255
+ props = {** props ,'animated' :self ._useblit }
3243
3256
self ._visible = props .pop ('visible' ,self ._visible )
3244
3257
to_draw = self ._init_shape (** props )
3245
3258
self .ax .add_patch (to_draw )
@@ -3264,18 +3277,18 @@ def __init__(self, ax, onselect=None, *, minspanx=0,
3264
3277
xc ,yc = self .corners
3265
3278
self ._corner_handles = ToolHandles (self .ax ,xc ,yc ,
3266
3279
marker_props = self ._handle_props ,
3267
- useblit = self .useblit )
3280
+ useblit = self ._useblit )
3268
3281
3269
3282
self ._edge_order = ['W' ,'S' ,'E' ,'N' ]
3270
3283
xe ,ye = self .edge_centers
3271
3284
self ._edge_handles = ToolHandles (self .ax ,xe ,ye ,marker = 's' ,
3272
3285
marker_props = self ._handle_props ,
3273
- useblit = self .useblit )
3286
+ useblit = self ._useblit )
3274
3287
3275
3288
xc ,yc = self .center
3276
3289
self ._center_handle = ToolHandles (self .ax , [xc ], [yc ],marker = 's' ,
3277
3290
marker_props = self ._handle_props ,
3278
- useblit = self .useblit )
3291
+ useblit = self ._useblit )
3279
3292
3280
3293
self ._active_handle = None
3281
3294
@@ -3782,7 +3795,7 @@ def __init__(self, ax, onselect=None, *, useblit=True, props=None, button=None):
3782
3795
** (props if props is not None else {}),
3783
3796
# Note that self.useblit may be != useblit, if the canvas doesn't
3784
3797
# support blitting.
3785
- 'animated' :self .useblit ,'visible' :False ,
3798
+ 'animated' :self ._useblit ,'visible' :False ,
3786
3799
}
3787
3800
line = Line2D ([], [],** props )
3788
3801
self .ax .add_line (line )
@@ -3906,7 +3919,7 @@ def __init__(self, ax, onselect=None, *, useblit=False,
3906
3919
3907
3920
if props is None :
3908
3921
props = dict (color = 'k' ,linestyle = '-' ,linewidth = 2 ,alpha = 0.5 )
3909
- props = {** props ,'animated' :self .useblit }
3922
+ props = {** props ,'animated' :self ._useblit }
3910
3923
self ._selection_artist = line = Line2D ([], [],** props )
3911
3924
self .ax .add_line (line )
3912
3925
@@ -3915,7 +3928,7 @@ def __init__(self, ax, onselect=None, *, useblit=False,
3915
3928
markerfacecolor = props .get ('color' ,'k' ))
3916
3929
self ._handle_props = handle_props
3917
3930
self ._polygon_handles = ToolHandles (self .ax , [], [],
3918
- useblit = self .useblit ,
3931
+ useblit = self ._useblit ,
3919
3932
marker_props = self ._handle_props )
3920
3933
3921
3934
self ._active_handle_idx = - 1
@@ -3935,7 +3948,7 @@ def _get_bbox(self):
3935
3948
3936
3949
def _add_box (self ):
3937
3950
self ._box = RectangleSelector (self .ax ,
3938
- useblit = self .useblit ,
3951
+ useblit = self ._useblit ,
3939
3952
grab_range = self .grab_range ,
3940
3953
handle_props = self ._box_handle_props ,
3941
3954
props = self ._box_props ,
@@ -4215,7 +4228,7 @@ class Lasso(AxesWidget):
4215
4228
def __init__ (self ,ax ,xy ,callback ,* ,useblit = True ,props = None ):
4216
4229
super ().__init__ (ax )
4217
4230
4218
- self .useblit = useblit and self .canvas .supports_blit
4231
+ self .useblit = useblit and self .canvas .supports_blit # TODO: Make dynamic
4219
4232
if self .useblit :
4220
4233
self .background = self .canvas .copy_from_bbox (self .ax .bbox )
4221
4234