[Matplotlib-devel] Event handling callbacks call order

Daniele Nicolodi daniele at grinta.net
Wed Feb 13 19:46:32 EST 2019


I have an application where I let the user place Patches on the canvas
via mouse events. To do so I have a "button_press_event" callback
registered to the canvas. I now would like to allow to drag the drawn
patches to change their position. To do so I register other callbacks on
the canvas like in the examples at
https://matplotlib.org/users/event_handling.html. The problem is that
the callbacks are called in the order they are registered and I haven't
found a way to inhibit execution of callbacks down the stack from
previously called callback. This results in the fact that patches are
drawn on top of the old ones when the user tries to drag those around.

I can see (quite convoluted) ways to avoid this in my code, but I would
think that correctly handling this is a common occurrence and that there
could be a solution built into matplotlib. However, I haven't found it.

I am missing something?

Thank you!


More information about the Matplotlib-devel mailing list