On Thu, Sep 23, 2010 at 9:16 AM, David Trémouilles <david.t...@gmail.com> 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

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

------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to