[Matplotlib-devel] Event handling callbacks call order

Antony Lee antony.lee at institutoptique.fr
Thu Feb 14 05:26:44 EST 2019


Hi,
A simple way to do this would be for the first handler to attach e.g. a
"handled" ("accepted", in Qt terminology) attribute to the event and for
later handlers to first check whether that attribute exists.  Note that
this can be done independently of anything provided by Matplotlib itself
(Matplotlib could automatically stop propagating events with that attribute
set, but I'm not sure it's really worth it).
Cheers,
Antony

On Thu, Feb 14, 2019 at 1:56 AM Daniele Nicolodi <daniele at grinta.net> wrote:

> Hello,
>
> 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!
>
> Cheers,
> Dan
> _______________________________________________
> Matplotlib-devel mailing list
> Matplotlib-devel at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-devel/attachments/20190214/b863ef0d/attachment.html>


More information about the Matplotlib-devel mailing list