fig.canvas.mpl_connect()怎么同时开启使用键盘和鼠标
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
text = ax.text(0.5, 0.5, 'event', ha='center', va='center', fontdict={'size': 20})
def call_back(event):
print(event.button)
print(event.key)
fig.canvas.mpl_connect('key_press_event', call_back)
fig.canvas.mpl_connect('button_press_event',call_back)
plt.show()
程序运行后会有以下报错:
print(event.button)
AttributeError: 'KeyEvent' object has no attribute 'button'