8000 Added "val" attribute to widgets.RadioButtons by DanHickstein · Pull Request #3971 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Added "val" attribute to widgets.RadioButtons #3971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 8, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
including self.val to allow the user to get the current status of the…
… radioButtons.
  • Loading branch information
DanHickstein committed Jan 6, 2015
commit 9a6a92ce536cf5211028026aaea7bc56f98842fe
6 changes: 5 additions & 1 deletion lib/matplotlib/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,9 @@ class RadioButtons(AxesWidget):

*circles*
A list of :class:`matplotlib.patches.Circle` instances

*val*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW - I don't see a good reason not to be very explicit about the name of the variable. value would be good, selected_value would be even better...

A string listing the current value selected

Connect to the RadioButtons with the :meth:`on_clicked` method
"""
Expand All @@ -644,7 +647,6 @@ def __init__(self, ax, labels, active=0, activecolor='blue'):
The color of the button when clicked
"""
AxesWidget.__init__(self, ax)

self.activecolor = activecolor

ax.set_xticks([])
Expand All @@ -663,6 +665,7 @@ def __init__(self, ax, labels, active=0, activecolor='blue'):
verticalalignment='center')

if cnt == active:
self.val = label
facecolor = activecolor
else:
facecolor = axcolor
Expand Down Expand Up @@ -698,6 +701,7 @@ def inside(p):
if t.get_window_extent().contains(event.x, event.y) or inside(p):
inp = p
thist = t
self.val = t.get_text()
break
else:
return
Expand Down
0