Bug with restore_background when mpl is embedded in wxpython

Hi,
Restore_region does not appear to work when embedding mpl into
wxpython. Attached is a simple modification of the cookbook animation
(http://www.scipy.org/Cookbook/Matplotlib/Animations) to illustrate
this problem. I modified the example so it is updated on mouse
movements (followed by idle time) so that the problem is more visual.
There is also a flag to add one second timeouts between commands in
the update method. When looking at the slowed animation it is clear
that the background is never restored.
Michiel Hoon thinks that the problem is due to the fact that
restore_region is not implemented within the event loop and that the
proper solution requires discussion:)

Elan

anim.py (2.72 KB)

···

---
Of joys departed, not to return, how painful the remembrance.
- Robert Blair

Here is a slightly modified version of your script which works for me.

I don't think this is the bug in mpl. Note that the ax.bbox does
change if the canvas size change. In your original script, the
copy_from_bbox is called before frame.Show() and this seems to cause a
mismatching bbox.

My modified example is also not perfect. A new background image needs
to be saved whenever ax.bbox changes (e.g. when resizing canvas).

-JJ

anim2.py (2.65 KB)

···

On Fri, May 8, 2009 at 5:02 PM, Elan Pavlov <epavlov@...149...> wrote:

Hi,
Restore_region does not appear to work when embedding mpl into
wxpython. Attached is a simple modification of the cookbook animation
(http://www.scipy.org/Cookbook/Matplotlib/Animations) to illustrate
this problem. I modified the example so it is updated on mouse
movements (followed by idle time) so that the problem is more visual.
There is also a flag to add one second timeouts between commands in
the update method. When looking at the slowed animation it is clear
that the background is never restored.
Michiel Hoon thinks that the problem is due to the fact that
restore_region is not implemented within the event loop and that the
proper solution requires discussion:)

Elan
---
Of joys departed, not to return, how painful the remembrance.
- Robert Blair

------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

probably best way to do this is to connect to the draw_event, and
update the background on the draw_event. I've updated the example and
attached it -- do you mind if I commit it to the mpl examples dir (and
does this solve all the issues you are having)?

JDH

anim3.py (2.67 KB)

···

On Sat, May 9, 2009 at 12:08 PM, Jae-Joon Lee <lee.j.joon@...149...> wrote:

Here is a slightly modified version of your script which works for me.

I don't think this is the bug in mpl. Note that the ax.bbox does
change if the canvas size change. In your original script, the
copy_from_bbox is called before frame.Show() and this seems to cause a
mismatching bbox.

My modified example is also not perfect. A new background image needs
to be saved whenever ax.bbox changes (e.g. when resizing canvas).

Hi John and Jae-Joon,
While it hardly solves *all* of the issues I've been having it does work for this problem:) Thanks a ton. As for committing it to the repository I'd be honored if Jae Joon agrees. Should I clean it up and remove the debugging prints?

Elan

···

----
"If stupidity got us into this mess, why can't it get us out?"
   - Will Rogers

On Sat, 9 May 2009, John Hunter wrote:

On Sat, May 9, 2009 at 12:08 PM, Jae-Joon Lee <lee.j.joon@...149...> wrote:

Here is a slightly modified version of your script which works for me.

I don't think this is the bug in mpl. Note that the ax.bbox does
change if the canvas size change. In your original script, the
copy_from_bbox is called before frame.Show() and this seems to cause a
mismatching bbox.

My modified example is also not perfect. A new background image needs
to be saved whenever ax.bbox changes (e.g. when resizing canvas).

probably best way to do this is to connect to the draw_event, and
update the background on the draw_event. I've updated the example and
attached it -- do you mind if I commit it to the mpl examples dir (and
does this solve all the issues you are having)?

JDH

Sure,

-JJ

···

On Sat, May 9, 2009 at 7:05 PM, Elan Pavlov <elan@...608...> wrote:

As for committing it to the repository I'd be honored if Jae Joon agrees.