Mouse event blocked in 1.0 but works with 0.93 ?

Hello,

  I've just updated matplotlib to 1.0 svn version from 0.93.
My pyqt4 app use the pick event. Cliking on a point in the graph
triggers an event but with matplotlib 1.0 it does not anymore while
it was working fine with 0.93.
Any idea/help on where I should look for ?

Thanks in advance,

David

Hi David,

I’m using the pick event in wx (matplotlib 1.0) without any issues. Could you please post some sample code? Have you tried to see if legend.draggable() works? If so, the pick event is likely not an issue.

-Aman

···

On Thu, Sep 23, 2010 at 4:20 AM, David Trémouilles <david.trem@…287…> wrote:

Hello,

I’ve just updated matplotlib to 1.0 svn version from 0.93.

My pyqt4 app use the pick event. Cliking on a point in the graph

triggers an event but with matplotlib 1.0 it does not anymore while

it was working fine with 0.93.

Any idea/help on where I should look for ?

Thanks in advance,

David


Start uncovering the many advantages of virtual appliances

and start using them to simplify application deployment and

accelerate your shift to cloud computing.

http://p.sf.net/sfu/novell-sfdev2dev


Matplotlib-users mailing list

Matplotlib-users@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Not without a better idea of what you're doing. I *can* say that both
picking examples work fine for me with the Qt4Agg backend. Can you
create a complete, minimal example that replicates the problem you're
seeing? Without that, I'd just be guessing blindly.

Ryan

···

On Thu, Sep 23, 2010 at 3:20 AM, David Trémouilles <david.trem@...287...> wrote:

Hello,

I've just updated matplotlib to 1.0 svn version from 0.93.
My pyqt4 app use the pick event. Cliking on a point in the graph
triggers an event but with matplotlib 1.0 it does not anymore while
it was working fine with 0.93.
Any idea/help on where I should look for ?

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

OK, was able to narrow thinks down:
actually it looks like
figure.canvas.mpl_connect('pick_event', function)
does not connect the "function" if it is a class method (...?)
In attachment you will find two files illustrating this:
buggy_pick.py and buggy_pick2.py
Both work nicely with matplotlib 0.93
With matplotlib 1.0 buggy_pick.py does not work while buggy_pick2.py does work.
The only difference is in the PickFig class...

Is it really a bug or I'm doing something wrong ?

Any workaround would be welcome.

Thx,

David

PS. Is it better to discuss this on users or devel list ?

Le 23/09/10 15:42, Ryan May a �crit :

buggy_pick.py (2.39 KB)

buggy_pick2.py (2.19 KB)

···

On Thu, Sep 23, 2010 at 3:20 AM, David Tr�mouilles<david.trem@...287...> wrote:

Hello,

  I've just updated matplotlib to 1.0 svn version from 0.93.
My pyqt4 app use the pick event. Cliking on a point in the graph
triggers an event but with matplotlib 1.0 it does not anymore while
it was working fine with 0.93.
Any idea/help on where I should look for ?

Not without a better idea of what you're doing. I *can* say that both
picking examples work fine for me with the Qt4Agg backend. Can you
create a complete, minimal example that replicates the problem you're
seeing? Without that, I'd just be guessing blindly.

Ryan

Technically, you're doing something sort of wrong, though it's very
subtle. And it just so happens that the way the code for callbacks was
reworked that this even showed up.
In this code:

class TestFig(MatplotlibFig):
    def __init__(self, parent=None):
        MatplotlibFig.__init__(self, parent)
        PickFig(self.figure)

You create a PickFig, but since you don't assign it to anything, it
gets garbage collected and (eventually) removed from the callbacks.
Previously, the callback registry would have a reference to the
callbacks, which would have kept PickFig alive. This was changed to
eliminate some resource leaks. The fix is simple, just save the
PickFig as a member of TestFig:

self.pf = PickFig(self.figure)

That fixes the problem for me.

Ryan

···

On Thu, Sep 23, 2010 at 9:16 AM, David Trémouilles <david.trem@...287...> wrote:

OK, was able to narrow thinks down:
actually it looks like
figure.canvas.mpl_connect('pick_event', function)
does not connect the "function" if it is a class method (...?)
In attachment you will find two files illustrating this:
buggy_pick.py and buggy_pick2.py
Both work nicely with matplotlib 0.93
With matplotlib 1.0 buggy_pick.py does not work while buggy_pick2.py does
work.
The only difference is in the PickFig class...

Is it really a bug or I'm doing something wrong ?

Any workaround would be welcome.

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

Wonderful !
This does indeed solve my issue.

Many many thanks,

David

Le 23/09/10 17:35, Ryan May a �crit :

···

On Thu, Sep 23, 2010 at 9:16 AM, David Tr�mouilles<david.trem@...287...> wrote:

OK, was able to narrow thinks down:
actually it looks like
figure.canvas.mpl_connect('pick_event', function)
does not connect the "function" if it is a class method (...?)
In attachment you will find two files illustrating this:
buggy_pick.py and buggy_pick2.py
Both work nicely with matplotlib 0.93
With matplotlib 1.0 buggy_pick.py does not work while buggy_pick2.py does
work.
The only difference is in the PickFig class...

Is it really a bug or I'm doing something wrong ?

Any workaround would be welcome.

Technically, you're doing something sort of wrong, though it's very
subtle. And it just so happens that the way the code for callbacks was
reworked that this even showed up.
In this code:

class TestFig(MatplotlibFig):
     def __init__(self, parent=None):
         MatplotlibFig.__init__(self, parent)
         PickFig(self.figure)

You create a PickFig, but since you don't assign it to anything, it
gets garbage collected and (eventually) removed from the callbacks.
Previously, the callback registry would have a reference to the
callbacks, which would have kept PickFig alive. This was changed to
eliminate some resource leaks. The fix is simple, just save the
PickFig as a member of TestFig:

self.pf = PickFig(self.figure)

That fixes the problem for me.

Ryan