@@ -235,18 +235,17 @@ def _motion(self, event):
235
235
236
236
def on_clicked (self , func ):
237
237
"""
238
- When the button is clicked, call this *func* with event .
238
+ Connect the callback function *func* to button click events .
239
239
240
- A connection id is returned. It can be used to disconnect
241
- the button from its callback.
240
+ Returns a connection id, which can be used to disconnect the callback.
242
241
"""
243
242
cid = self .cnt
244
243
self .observers [cid ] = func
245
244
self .cnt += 1
246
245
return cid
247
246
248
247
def disconnect (self , cid ):
249
- """remove the observer with connection id *cid*"""
248
+ """Remove the callback function with connection id *cid*. """
250
249
try :
251
250
del self .observers [cid ]
252
251
except KeyError :
@@ -648,9 +647,9 @@ def get_status(self):
648
647
649
648
def on_clicked (self , func ):
650
649
"""
651
- When the button is clicked, call *func* with button label
650
+ Connect the callback function *func* to button click events.
652
651
653
- A connection id is returned which can be used to disconnect
652
+ Returns a connection id, which can be used to disconnect the callback.
654
653
"""
655
654
cid = self .cnt
656
655
self .observers [cid ] = func
@@ -974,40 +973,40 @@ class RadioButtons(AxesWidget):
974
973
"""
975
974
A GUI neutral radio button.
976
975
977
- For the buttons to remain responsive
978
- you must keep a reference to this object.
979
-
980
- The following attributes are exposed:
981
-
982
- *ax*
983
- The :class:`matplotlib.axes.Axes` instance the buttons are in
984
-
985
- *activecolor*
986
- The color of the button when clicked
976
+ For the buttons to remain responsive you must keep a reference to this
977
+ object.
987
978
988
- *labels*
989
- A list of :class:`matplotlib.text.Text` instances
979
+ Connect to the RadioButtons with the :meth:`on_clicked` method.
990
980
991
- *circles*
992
- A list of :class:`matplotlib.patches.Circle` instances
993
981
994
- *value_selected*
995
- A string listing the current value selected
982
+ Attributes
983
+ ----------
984
+ ax
985
+ The containing `~.axes.Axes` instance.
986
+ activecolor
987
+ The color of the selected button.
988
+ labels
989
+ A list of `~.text.Text` instances containing the button labels.
990
+ circles
991
+ A list of `~.patches.Circle` instances defining the buttons.
992
+ value_selected : str
993
+ The label text of the currently selected button.
996
994
997
- Connect to the RadioButtons with the :meth:`on_clicked` method
998
995
"""
999
996
def __init__ (self , ax , labels , active = 0 , activecolor = 'blue' ):
1000
997
"""
1001
- Add radio buttons to :class:`matplotlib.axes.Axes` instance *ax*
1002
-
1003
- *labels*
1004
- A len(buttons) list of labels as strings
998
+ Add radio buttons to an `~.axes.Axes`.
1005
999
1006
- *active*
1007
- The index into labels for the button that is active
1008
-
1009
- *activecolor*
1010
- The color of the button when clicked
1000
+ Parameters
1001
+ ----------
1002
+ ax : `~matplotlib.axes.Axes`
1003
+ The axes to add the buttons to.
1004
+ labels : list of str
1005
+ The button labels.
1006
+ active : int
1007
+ The index of the initially selected button.
1008
+ activecolor : color
1009
+ The color of the selected button.
1011
1010
"""
1012
1011
AxesWidget .__init__ (self , ax )
1013
1012
self .activecolor = activecolor
@@ -1067,14 +1066,9 @@ def _clicked(self, event):
1067
1066
1068
1067
def set_active (self , index ):
1069
1068
"""
1070
- Trigger which radio button to make active.
1071
-
1072
- *index* is an index into the original label list
1073
- that this object was constructed with.
1074
- Raise ValueError if the index is invalid.
1069
+ Select button with number *index*.
1075
1070
1076
1071
Callbacks will be triggered if :attr:`eventson` is True.
1077
-
1078
1072
"""
1079
1073
if 0 > index >= len (self .labels ):
1080
1074
raise ValueError ("Invalid RadioButton index: %d" % index )
@@ -1098,17 +1092,17 @@ def set_active(self, index):
1098
1092
1099
1093
def on_clicked (self , func ):
1100
1094
"""
1101
- When the button is clicked, call *func* with button label
1095
+ Connect the callback function *func* to button click events.
1102
1096
1103
- A connection id is returned which can be used to disconnect
1097
+ Returns a connection id, which can be used to disconnect the callback.
1104
1098
"""
1105
1099
cid = self .cnt
1106
1100
self .observers [cid ] = func
1107
1101
self .cnt += 1
1108
1102
return cid
1109
1103
1110
1104
def disconnect (self , cid ):
1111
- """remove the observer with connection id *cid*"""
1105
+ """Remove the observer with connection id *cid*. """
1112
1106
try :
1113
1107
del self .observers [cid ]
1114
1108
except KeyError :
0 commit comments