I use the cursor widget in the Matplotlib interactive graph as follows:
cursor = Cursor(ax1, useblit=True, color='red', linewidth=1)
cid = fig.canvas.mpl_connect('button_press_event', on_click)
It works well. The function on_clicktakes x, y click locations and makes some additional graphs. The main things.
When I activate the zoom tool, I also fix the click. Do I need to associate the activation and deactivation of the key stroke with widgets a la the RectangleSelector or is there a method that knows the state of the toolbar elements?
An example of turning on / off the selector from the RectangleSelector example:
def toggle_selector(event):
if event.key in ['Q','q'] and toggle_selector.RS.active:
toggle_selector.RS.set_active(False)
if event.key in ['A', 'a'] and not toggle_selector.RS.active:
toggle_selector.RS.set_active(True)
source
share