Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 580d990

Browse files
committed
Merge pull request #3971 from DanHickstein/master
ENH : Added "value_selected" attribute to widgets.RadioButtons
2 parents d014a8d + 6ecf852 commit 580d990

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/matplotlib/widgets.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,9 @@ class RadioButtons(AxesWidget):
627627
628628
*circles*
629629
A list of :class:`matplotlib.patches.Circle` instances
630+
631+
*value_selected*
632+
A string listing the current value selected
630633
631634
Connect to the RadioButtons with the :meth:`on_clicked` method
632635
"""
@@ -644,8 +647,8 @@ def __init__(self, ax, labels, active=0, activecolor='blue'):
644647
The color of the button when clicked
645648
"""
646649
AxesWidget.__init__(self, ax)
647-
648650
self.activecolor = activecolor
651+
self.value_selected = None
649652

650653
ax.set_xticks([])
651654
ax.set_yticks([])
@@ -663,6 +666,7 @@ def __init__(self, ax, labels, active=0, activecolor='blue'):
663666
verticalalignment='center')
664667

665668
if cnt == active:
669+
self.value_selected = label
666670
facecolor = activecolor
667671
else:
668672
facecolor = axcolor
@@ -698,6 +702,7 @@ def inside(p):
698702
if t.get_window_extent().contains(event.x, event.y) or inside(p):
699703
inp = p
700704
thist = t
705+
self.value_selected = t.get_text()
701706
break
702707
else:
703708
return

0 commit comments

Comments
 (0)