Taro Sato-4 wrote:
> 
> Hello.  I'm trying to embed mpl in an wxpython app which is intended
> to run repeatedly within a single script.  (It's a workaround for not
> being able to use pyplot.show() more than once in a script.)
> 
> All seems to work as intended when I don't attach any key press events
> (here to just destroy the app) to canvas, but when I do, as in the
> script below, for some reason I keep getting errors that appear to
> indicate that some remnant of the zombie of the previous app instance
> may be sticking around when they shouldn't exist.  Both the script in
> question and the (typical) error message are shown below in this
> message.
> 
> 

I think I figured out what causes wx._core.PyDeadObjectError above.

In backend_bases.py, LocationEvent class has the attribute lastevent
(initially set to None) which keeps the Event instance of a previous event. 
LocationEvent._update_enter_leave() method processes axes_leave_event for
lastevent if not None, and then processes axes_enter_event for the current
event.

When an application window first gets created, lastevent is set to None. 
When the application is destroyed and a new instance of the application is
created, lastevent needs to be reset to None, which apparently is not
happening.  The reference to the previous event which occurred within the
destroyed application is being accessed via lastevent, hence the
PyDeadObjectError.

I'm not sure what the best timing is to rest lastevent (I'm not thoroughly
familiar with mpl source codes).  But modifying
LocationEvent._update_enter_leave() such that the PyDeadObjectError
exception raised by accessing lastevent solves the specific issue in the
original post.  

Should I file a bug report on this?

Cheers,
Taro


-- 
View this message in context: 
http://old.nabble.com/Strange-event-errors-with-WXAgg-%2B-wx-tp26312977p26355887.html
Sent from the matplotlib - users mailing list archive at Nabble.com.


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to