Skip to content

Commit d2814cf

Browse files
committed
CheckButtons: rename _checks to _buttons
For more consistency and similarity with RadioButtons
1 parent 015013c commit d2814cf

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

lib/matplotlib/widgets.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ def __init__(self, ax, labels, actives=None, *, useblit=True,
11401140
# overhead on unsupported backends.
11411141
}
11421142
check_props.setdefault('facecolor', check_props.pop('color', 'black'))
1143-
self._checks = ax.scatter([0.15] * len(ys), ys, **check_props)
1143+
self._buttons = ax.scatter([0.15] * len(ys), ys, **check_props)
11441144
# The user may have passed custom colours in check_props, so we need to
11451145
# create the checks (above), and modify the visibility after getting
11461146
# whatever the user set.
@@ -1158,7 +1158,7 @@ def _clear(self, event):
11581158
return
11591159
if self._useblit and self.canvas.supports_blit:
11601160
self._save_blit_background(self.canvas.copy_from_bbox(self.ax.bbox))
1161-
self.ax.draw_artist(self._checks)
1161+
self.ax.draw_artist(self._buttons)
11621162

11631163
@_call_with_reparented_event
11641164
def _clicked(self, event):
@@ -1223,7 +1223,7 @@ def set_check_props(self, props):
12231223
if 's' in props: # Keep API consistent with constructor.
12241224
props['sizes'] = np.broadcast_to(props.pop('s'), len(self.labels))
12251225
actives = self.get_status()
1226-
self._checks.update(props)
1226+
self._buttons.update(props)
12271227
# If new colours are supplied, then we must re-apply the status.
12281228
self._init_status(actives)
12291229

@@ -1255,18 +1255,18 @@ def set_active(self, index, state=None):
12551255

12561256
invisible = colors.to_rgba('none')
12571257

1258-
facecolors = self._checks.get_facecolor()
1258+
facecolors = self._buttons.get_facecolor()
12591259
if state is None:
12601260
state = colors.same_color(facecolors[index], invisible)
12611261
facecolors[index] = self._active_check_colors[index] if state else invisible
1262-
self._checks.set_facecolor(facecolors)
1262+
self._buttons.set_facecolor(facecolors)
12631263

12641264
if self.drawon:
12651265
if self._useblit and self.canvas.supports_blit:
12661266
background = self._load_blit_background()
12671267
if background is not None:
12681268
self.canvas.restore_region(background)
1269-
self.ax.draw_artist(self._checks)
1269+
self.ax.draw_artist(self._buttons)
12701270
self.canvas.blit(self.ax.bbox)
12711271
else:
12721272
self.canvas.draw()
@@ -1282,18 +1282,18 @@ def _init_status(self, actives):
12821282
constructor, or to `.set_check_props`, so we need to modify the
12831283
visibility after getting whatever the user set.
12841284
"""
1285-
self._active_check_colors = self._checks.get_facecolor()
1285+
self._active_check_colors = self._buttons.get_facecolor()
12861286
if len(self._active_check_colors) == 1:
12871287
self._active_check_colors = np.repeat(self._active_check_colors,
12881288
len(actives), axis=0)
1289-
self._checks.set_facecolor(
1289+
self._buttons.set_facecolor(
12901290
[ec if active else "none"
12911291
for ec, active in zip(self._active_check_colors, actives)])
12921292

12931293
def clear(self):
12941294
"""Uncheck all checkboxes."""
12951295

1296-
self._checks.set_facecolor(['none'] * len(self._active_check_colors))
1296+
self._buttons.set_facecolor(['none'] * len(self._active_check_colors))
12971297

12981298
if hasattr(self, '_lines'):
12991299
for l1, l2 in self._lines:
@@ -1312,7 +1312,7 @@ def get_status(self):
13121312
Return a list of the status (True/False) of all of the check buttons.
13131313
"""
13141314
return [not colors.same_color(color, colors.to_rgba("none"))
1315-
for color in self._checks.get_facecolors()]
1315+
for color in self._buttons.get_facecolors()]
13161316

13171317
def get_checked_labels(self):
13181318
"""Return a list of labels currently checked by user."""

0 commit comments

Comments
 (0)