@@ -222,7 +222,7 @@ def __init__(self, ax, label, image=None,
222222horizontalalignment = 'center' ,
223223transform = ax .transAxes )
224224
225- self ._useblit = useblit and self . canvas . supports_blit
225+ self ._useblit = useblit
226226
227227self ._observers = cbook .CallbackRegistry (signals = ["clicked" ])
228228
@@ -256,7 +256,7 @@ def _motion(self, event):
256256if not colors .same_color (c ,self .ax .get_facecolor ()):
257257self .ax .set_facecolor (c )
258258if self .drawon :
259- if self ._useblit :
259+ if self ._useblit and self . canvas . supports_blit :
260260self .ax .draw_artist (self .ax )
261261self .canvas .blit (self .ax .bbox )
262262else :
@@ -1078,7 +1078,7 @@ def __init__(self, ax, labels, actives=None, *, useblit=True,
10781078if actives is None :
10791079actives = [False ]* len (labels )
10801080
1081- self ._useblit = useblit and self .canvas .supports_blit
1081+ self ._useblit = useblit and self .canvas .supports_blit # TODO: make dynamic
10821082
10831083ys = np .linspace (1 ,0 ,len (labels )+ 2 )[1 :- 1 ]
10841084
@@ -1665,7 +1665,7 @@ def __init__(self, ax, labels, active=0, activecolor=None, *,
16651665
16661666ys = np .linspace (1 ,0 ,len (labels )+ 2 )[1 :- 1 ]
16671667
1668- self ._useblit = useblit and self .canvas .supports_blit
1668+ self ._useblit = useblit and self .canvas .supports_blit # TODO: make dynamic
16691669
16701670label_props = _expand_text_props (label_props )
16711671self .labels = [
@@ -1951,7 +1951,7 @@ def __init__(self, ax, *, horizOn=True, vertOn=True, useblit=False,
19511951self .visible = True
19521952self .horizOn = horizOn
19531953self .vertOn = vertOn
1954- self .useblit = useblit and self .canvas .supports_blit
1954+ self .useblit = useblit and self .canvas .supports_blit # TODO: make dynamic
19551955
19561956if self .useblit :
19571957lineprops ['animated' ]= True
@@ -2060,6 +2060,7 @@ def __init__(self, canvas, axes, *, useblit=True, horizOn=False, vertOn=True,
20602060self .useblit = (
20612061useblit
20622062and all (canvas .supports_blit for canvas in self ._canvas_infos ))
2063+ # TODO: make dynamic
20632064
20642065if self .useblit :
20652066lineprops ['animated' ]= True
@@ -2144,7 +2145,7 @@ def __init__(self, ax, onselect=None, useblit=False, button=None,
21442145self .onselect = lambda * args :None
21452146else :
21462147self .onselect = onselect
2147- self .useblit = useblit and self . canvas . supports_blit
2148+ self ._useblit = useblit
21482149self .connect_default_events ()
21492150
21502151self ._state_modifier_keys = dict (move = ' ' ,clear = 'escape' ,
@@ -2168,6 +2169,11 @@ def __init__(self, ax, onselect=None, useblit=False, button=None,
21682169self ._prev_event = None
21692170self ._state = set ()
21702171
2172+ @property
2173+ def useblit (self ):
2174+ """Return whether blitting is used (requested and supported by canvas)."""
2175+ return self ._useblit and self .canvas .supports_blit
2176+
21712177def set_active (self ,active ):
21722178super ().set_active (active )
21732179if active :
@@ -2590,7 +2596,14 @@ def __init__(self, ax, onselect, direction, *, minspan=0, useblit=False,
25902596if props is None :
25912597props = dict (facecolor = 'red' ,alpha = 0.5 )
25922598
2593- props ['animated' ]= self .useblit
2599+ # Note: We set this based on the user setting during ínitialization,
2600+ # not on the actual capability of blitting. But the value is
2601+ # irrelevant if the backend does not support blitting, so that
2602+ # we don't have to dynamically update this on the backend.
2603+ # This relies on the current behavior that the request for
2604+ # useblit is fixed during initialization and cannot be changed
2605+ # afterwards.
2606+ props ['animated' ]= self ._useblit
25942607
25952608self .direction = direction
25962609self ._extents_on_press = None
@@ -2656,7 +2669,7 @@ def _setup_edge_handles(self, props):
26562669self ._edge_handles = ToolLineHandles (self .ax ,positions ,
26572670direction = self .direction ,
26582671line_props = props ,
2659- useblit = self .useblit )
2672+ useblit = self ._useblit )
26602673
26612674@property
26622675def _handles_artists (self ):
@@ -3223,7 +3236,7 @@ def __init__(self, ax, onselect=None, *, minspanx=0,
32233236if props is None :
32243237props = dict (facecolor = 'red' ,edgecolor = 'black' ,
32253238alpha = 0.2 ,fill = True )
3226- props = {** props ,'animated' :self .useblit }
3239+ props = {** props ,'animated' :self ._useblit }
32273240self ._visible = props .pop ('visible' ,self ._visible )
32283241to_draw = self ._init_shape (** props )
32293242self .ax .add_patch (to_draw )
@@ -3248,18 +3261,18 @@ def __init__(self, ax, onselect=None, *, minspanx=0,
32483261xc ,yc = self .corners
32493262self ._corner_handles = ToolHandles (self .ax ,xc ,yc ,
32503263marker_props = self ._handle_props ,
3251- useblit = self .useblit )
3264+ useblit = self ._useblit )
32523265
32533266self ._edge_order = ['W' ,'S' ,'E' ,'N' ]
32543267xe ,ye = self .edge_centers
32553268self ._edge_handles = ToolHandles (self .ax ,xe ,ye ,marker = 's' ,
32563269marker_props = self ._handle_props ,
3257- useblit = self .useblit )
3270+ useblit = self ._useblit )
32583271
32593272xc ,yc = self .center
32603273self ._center_handle = ToolHandles (self .ax , [xc ], [yc ],marker = 's' ,
32613274marker_props = self ._handle_props ,
3262- useblit = self .useblit )
3275+ useblit = self ._useblit )
32633276
32643277self ._active_handle = None
32653278
@@ -3744,7 +3757,7 @@ def __init__(self, ax, onselect=None, *, useblit=True, props=None, button=None):
37443757** (props if props is not None else {}),
37453758# Note that self.useblit may be != useblit, if the canvas doesn't
37463759# support blitting.
3747- 'animated' :self .useblit ,'visible' :False ,
3760+ 'animated' :self ._useblit ,'visible' :False ,
37483761 }
37493762line = Line2D ([], [],** props )
37503763self .ax .add_line (line )
@@ -3868,7 +3881,7 @@ def __init__(self, ax, onselect=None, *, useblit=False,
38683881
38693882if props is None :
38703883props = dict (color = 'k' ,linestyle = '-' ,linewidth = 2 ,alpha = 0.5 )
3871- props = {** props ,'animated' :self .useblit }
3884+ props = {** props ,'animated' :self ._useblit }
38723885self ._selection_artist = line = Line2D ([], [],** props )
38733886self .ax .add_line (line )
38743887
@@ -3877,7 +3890,7 @@ def __init__(self, ax, onselect=None, *, useblit=False,
38773890markerfacecolor = props .get ('color' ,'k' ))
38783891self ._handle_props = handle_props
38793892self ._polygon_handles = ToolHandles (self .ax , [], [],
3880- useblit = self .useblit ,
3893+ useblit = self ._useblit ,
38813894marker_props = self ._handle_props )
38823895
38833896self ._active_handle_idx = - 1
@@ -3897,7 +3910,7 @@ def _get_bbox(self):
38973910
38983911def _add_box (self ):
38993912self ._box = RectangleSelector (self .ax ,
3900- useblit = self .useblit ,
3913+ useblit = self ._useblit ,
39013914grab_range = self .grab_range ,
39023915handle_props = self ._box_handle_props ,
39033916props = self ._box_props ,
@@ -4177,7 +4190,7 @@ class Lasso(AxesWidget):
41774190def __init__ (self ,ax ,xy ,callback ,* ,useblit = True ,props = None ):
41784191super ().__init__ (ax )
41794192
4180- self .useblit = useblit and self .canvas .supports_blit
4193+ self .useblit = useblit and self .canvas .supports_blit # TODO: Make dynamic
41814194if self .useblit :
41824195self .background = self .canvas .copy_from_bbox (self .ax .bbox )
41834196