Skip to content

Commit f701624

Browse files
committed
RadioButtons: fix self._clicked method (followup to matplotlib#30997)
In matplotlib#30997 the classes `RadioButtons` & `CheckButtons` started sharing more code, as they are fundamentally similar. When copy-pasting the methods that were seemingly identical, the `_clicked` method was copied from the original `CheckButtons` class, and there the `self._frames` object was used instead of `self._buttons`. This caused an error when actually using and clicking on buttons created with `RadioButtons`, as the `RadioButtons._frames` doesn't exist - something that unfortunately the tests did not catch. Both `CheckButtons._frames` and `CheckButtons._buttons` are very similar so even before matplotlib#30997 the `CheckButtons._clicked` method could have used `self._checks` and not `self._frames`. Hence this change should be harmless.
1 parent 8ea8f69 commit f701624

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/matplotlib/widgets.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,11 +1110,11 @@ def _clicked(self, event):
11101110
if self.ignore(event) or event.button != 1 or not self.ax.contains(event)[0]:
11111111
return
11121112
idxs = [ # Indices of frames and of texts that contain the event.
1113-
*self._frames.contains(event)[1]["ind"],
1113+
*self._buttons.contains(event)[1]["ind"],
11141114
*[i for i, text in enumerate(self.labels) if text.contains(event)[0]]]
11151115
if idxs:
1116-
coords = self._frames.get_offset_transform().transform(
1117-
self._frames.get_offsets())
1116+
coords = self._buttons.get_offset_transform().transform(
1117+
self._buttons.get_offsets())
11181118
self.set_active( # Closest index, only looking in idxs.
11191119
idxs[(((event.x, event.y) - coords[idxs]) ** 2).sum(-1).argmin()])
11201120

0 commit comments

Comments
 (0)