|
From: Mark B. <mar...@gm...> - 2012-09-07 23:38:34
|
Thanks Ben, that solved my issue. I guess I got thrown off because the plot stayed open, as you described. It's hard to troubleshoot when you don't get any errors. In the future I will attach all of my objects. -Mark On Fri, Sep 7, 2012 at 12:03 PM, Benjamin Root <ben...@ou...> wrote: > I think I see your problem... see below: > > > class start_lasso(): > def __init__(self): > data = [Datum(*xy) for xy in rand(100, 2)] > > fig = figure() > ax = fig.add_subplot(111, xlim=(0,1), ylim=(0,1), > autoscale_on=False) > lman = LassoManager(ax, data) > show() > > You aren't saving any of the objects created in the "start_lasso" class to > your start_lasso object. Luckily, with the way pyplot works, the figure > object your create gets implicitly saved to the "pyplot state manager" (a > sort of smart global location for the figure objects), and the axes object > gets implicitly attached to the figure object. Therefore, when the python > execution goes out of this scope, the figure object and the axes do not get > garbage-collected. However, the lasso widget that gets created and all the > callbacks that were attached are all done with weak references to the figure > and axes. So when you leave this scope, the LassoManager no longer exists > and the callback fails to execute (as designed). > > So, make sure that at least lman (and possibly fig and ax) gets saved to the > start_lasso object to solve that part of the problem. Next, you don't save > the start_lasso object your create anywhere, so even if you saved lman to > start_lasso, the start_lasso object gets garbage-collected anyway as a > temporary. > > I hope this is clear. Let me know if you still have more issues. > > Cheers! > Ben Root > |