擅长:python、mysql、java
<p>要获得该值,您可能需要将事件处理封装在一个类中,如<a href="http://matplotlib.org/users/event_handling.html" rel="noreferrer">official tutorial</a>:</p>
<pre><code>import matplotlib.pyplot as plt
from matplotlib.widgets import Button
class ButtonClickProcessor(object):
def __init__(self, axes, label):
self.button = Button(axes, label)
self.button.on_clicked(self.process)
def process(self, event):
print self.button.label
fig = plt.figure()
axnext = plt.axes([0.81, 0.05, 0.1, 0.075])
bnext = ButtonClickProcessor(axnext, "Next")
plt.show()
</code></pre>