matplotlib.widgets._Buttons#
- class matplotlib.widgets._Buttons(ax, labels, *, useblit=True, label_props=None, layout=None, **kwargs)[source]#
Bases:
AxesWidgetThe base class for
CheckButtonsandRadioButtons.This class provides common functionality for button widgets, such as handling click events, managing button labels, and connecting callbacks.
The class itself is private and may be changed or removed without prior warning. However, the public API it provides to subclasses is stable and considered public on the subclasses.
- on_clicked(func)[source]#
Connect the callback function func to button click events.
- Parameters:
- funccallable
When the button is clicked, call func with button label. When all buttons are cleared, call func with None. The callback func must have the signature:
def func(label: str | None) -> Any
Return values may exist, but are ignored.
- Returns:
- A connection id, which can be used to disconnect the callback.
- set_label_props(props)[source]#
Set properties of the
Textlabels.Added in version 3.7.
- Parameters:
- propsdict
Dictionary of
Textproperties to be used for the labels. Same format as label_props argument ofRadioButtonsorCheckButtons.