Parameters ---------- ax : `~matplotlib.axes.Axes` The `~.axes.Axes` instance the button will be placed into. label : str The button text. image : array-like or PIL Image The image to place in the button, if not *None*. Th
(self, ax, label, image=None,
color='0.85', hovercolor='0.95', *, useblit=True)
| 215 | """ |
| 216 | |
| 217 | def __init__(self, ax, label, image=None, |
| 218 | color='0.85', hovercolor='0.95', *, useblit=True): |
| 219 | """ |
| 220 | Parameters |
| 221 | ---------- |
| 222 | ax : `~matplotlib.axes.Axes` |
| 223 | The `~.axes.Axes` instance the button will be placed into. |
| 224 | label : str |
| 225 | The button text. |
| 226 | image : array-like or PIL Image |
| 227 | The image to place in the button, if not *None*. The parameter is |
| 228 | directly forwarded to `~.axes.Axes.imshow`. |
| 229 | color : :mpltype:`color` |
| 230 | The color of the button when not activated. |
| 231 | hovercolor : :mpltype:`color` |
| 232 | The color of the button when the mouse is over it. |
| 233 | useblit : bool, default: True |
| 234 | Use blitting for faster drawing if supported by the backend. |
| 235 | See the tutorial :ref:`blitting` for details. |
| 236 | |
| 237 | .. versionadded:: 3.7 |
| 238 | """ |
| 239 | super().__init__(ax) |
| 240 | |
| 241 | if image is not None: |
| 242 | ax.imshow(image) |
| 243 | self.label = ax.text(0.5, 0.5, label, |
| 244 | verticalalignment='center', |
| 245 | horizontalalignment='center', |
| 246 | transform=ax.transAxes) |
| 247 | |
| 248 | self._useblit = useblit |
| 249 | |
| 250 | self._observers = cbook.CallbackRegistry(signals=["clicked"]) |
| 251 | |
| 252 | self.connect_event('button_press_event', self._click) |
| 253 | self.connect_event('button_release_event', self._release) |
| 254 | self.connect_event('motion_notify_event', self._motion) |
| 255 | ax.set_navigate(False) |
| 256 | ax.set_facecolor(color) |
| 257 | ax.set_xticks([]) |
| 258 | ax.set_yticks([]) |
| 259 | self.color = color |
| 260 | self.hovercolor = hovercolor |
| 261 | |
| 262 | @_call_with_reparented_event |
| 263 | def _click(self, event): |
nothing calls this directly
no test coverage detected