Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 18906

How can I detect double click events in matplotlib?

$
0
0
import matplotlib.pyplot as pltdef onclick(event):    print(event.button)fig = plt.figure()connection_id = fig.canvas.mpl_connect('button_press_event', onclick)plt.show()

With this code, the problem is double-clicks are hitting onclick() handler three times. I guess that it is receiving both the clicks, as well as an additional double-click event.

How can I change this behavior so that the event handler is not fired for double-click events? Alternatively, how can I detect a double-click from the event instance so that I can ignore that case?

Note: button_release_event does not have this problem, but I want to fire on the button_press_event


Viewing all articles
Browse latest Browse all 18906


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>