MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / Button

Class Button

lib/matplotlib/widgets.py:198–301  ·  view source on GitHub ↗

A GUI neutral button. For the button to remain responsive you must keep a reference to it. Call `.on_clicked` to connect to the button. Attributes ---------- ax The `~.axes.Axes` the button renders into. label A `.Text` instance. color The c

Source from the content-addressed store, hash-verified

196
197
198class Button(AxesWidget):
199 """
200 A GUI neutral button.
201
202 For the button to remain responsive you must keep a reference to it.
203 Call `.on_clicked` to connect to the button.
204
205 Attributes
206 ----------
207 ax
208 The `~.axes.Axes` the button renders into.
209 label
210 A `.Text` instance.
211 color
212 The color of the button when not hovering.
213 hovercolor
214 The color of the button when hovering.
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)

Callers 4

buttons.pyFile · 0.90
slider_demo.pyFile · 0.90
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…