matplotlib (embedding_in_wx5.py) runs perfectly on Windows, but is not compatible with Mac OS X

matplotlib runs perfectly on Windows, but is not compatible with Mac OS X, cannot be scaled operation, does not refresh gui,have encountered this problem?

https://github.com/matplotlib/matplotlib/blob/master/examples/user_interfaces/embedding_in_wx5.py

Environment is: wxPython3.0 + matplotlib1.4 + Mac OS X10.8

Do you see the problem just with that example? Is e.g.
embedding_in_wx2.py scaling for you?
You might want to report this also to the mpl list:
Werner

···

Hi,

  On 9/2/2014 15:46, wrote:

goofcc@gmail.com

    matplotlib runs perfectly on Windows, but is not

compatible with Mac OS X, cannot be scaled
operation, does not refresh gui ,have
encountered this problem?

https://github.com/matplotlib/matplotlib/blob/master/examples/user_interfaces/embedding_in_wx5.py

          Environment is: wxPython3.0 + matplotlib1.4 + Mac OS X10.8

matplotlib-users@lists.sourceforge.net

I found that the scaling figure does not refresh。

在 2014年9月2日星期二UTC+8下午9时46分24秒,goo…@gmail.com写道:

···

matplotlib runs perfectly on Windows, but is not compatible with Mac OS X, cannot be scaled operation, does not refresh gui,have encountered this problem?

https://github.com/matplotlib/matplotlib/blob/master/examples/user_interfaces/embedding_in_wx5.py

Environment is: wxPython3.0 + matplotlib1.4 + Mac OS X10.8

Not embedding_in_wx2.py, I test example is embedding_in_wx5.py.

在 2014年9月3日星期三UTC+8上午12时12分29秒,werner写道:

···

Hi,

  On 9/2/2014 15:46, goo...@gmail.com wrote:
    matplotlib runs perfectly on Windows, but is not

compatible with Mac OS X, cannot be scaled
operation, does not refresh gui ,have
encountered this problem?

https://github.com/matplotlib/matplotlib/blob/master/examples/user_interfaces/embedding_in_wx5.py

          Environment is: wxPython3.0 + matplotlib1.4 + Mac OS X10.8
Do you see the problem just with that example?  Is e.g.

embedding_in_wx2.py scaling for you?

You might want to report this also to the mpl list:

matplotl...@lists.sourceforge.net

Werner

It is this effect, scaling, when the form is not refreshed。

在 2014年9月2日星期二UTC+8下午9时46分24秒,goo…@gmail.com写道:

···

matplotlib runs perfectly on Windows, but is not compatible with Mac OS X, cannot be scaled operation, does not refresh gui,have encountered this problem?

https://github.com/matplotlib/matplotlib/blob/master/examples/user_interfaces/embedding_in_wx5.py

Environment is: wxPython3.0 + matplotlib1.4 + Mac OS X10.8

wrote:
It’s been a couple years since I used MPL much, but IIRC this is a problem in the MPL code in how they are using wx.ClientDC. They are doing something like drawing with a wx.ClientDC while moving or sizing objects instead of triggering a normal paint event. This is a bad idea on any platform, but because of the design of the native UI code on OSX it just can’t work reliably there. In most cases a wx.ClientDC should only be used for things like measuring text or such, and drawing to the screen should be done in a paint event, triggered by a Refresh if needed, and perhaps forced to be immediate with a call to Update().
I don’t remember details, and unfortunately I don’t have access to that code anymore, but I think I was able to work around this issue in my project by overriding some things in a class derived from MPL’s canvas.

···

goofcc@gmail.com

It is this effect, scaling, when the form is not refreshed。


Robin Dunn

Software Craftsman

http://wxPython.org

Last I looked, the MPL wx code was a pretty ugly mess of clientDC, Blit(),
Refresh(), etc -- It started one way, then fixes were hacked on for
particular issues. It could really use some love, and a refactor to PaintDC
is probably what it needs.

If I need this to work for something, I may get in there and try to clean
it up -- but don't hold your breath, I've got too may other things on my
plate as it is. Sorry :frowning:

But if someone wants to dig in, I'll try to help if you have specific
questions.

-Chris

···

On Tue, Sep 23, 2014 at 6:04 PM, Robin Dunn <robin@alldunn.com> wrote:

goofcc@gmail.com wrote:

It's been a couple years since I used MPL much, but IIRC this is a problem
in the MPL code in how they are using wx.ClientDC. They are doing
something like drawing with a wx.ClientDC while moving or sizing objects
instead of triggering a normal paint event.

--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

I started some time ago some work on mpl (1.4) wx backends, main
focus was to get it to work with Phoenix and to run on Python 3, see
this PR: Outstanding issues is that the ‘wx’ backend does not show graphic as
of 2.9 (this seems to be an old issue) on Windows but it works on
Mac (tested by jenshnielsen) in e.g. the embedding_in_wx2.py example
and the issue mentioned in this thread.
The current code uses wx.PaintDC in the OnPaint handler, it uses
wx.MemoryDC especially in the ‘wxagg’ backend together with
wx.GraphicsContext and then there is wx.ClientDC in gui_repaint
method if it is called without a wx.PaintDC.
I wouldn’t mind trying but would definitely need help and some tips
on how to get going.
Werner

···

Hi Chris and OP,

  On 9/24/2014 18:28, Chris Barker wrote:
        On Tue, Sep 23, 2014 at 6:04 PM,

Robin Dunn robin@alldunn.com
wrote:

goofcc@gmail.com wrote:

            It's been a couple years since I used MPL much, but IIRC

this is a problem in the MPL code in how they are using
wx.ClientDC. They are doing something like drawing with
a wx.ClientDC while moving or sizing objects instead of
triggering a normal paint event.

          Last I looked, the MPL wx code was a pretty ugly mess

of clientDC, Blit(), Refresh(), etc – It started one way,
then fixes were hacked on for particular issues. It could
really use some love, and a refactor to PaintDC is
probably what it needs.

          If I need this to work for something, I may get in

there and try to clean it up – but don’t hold your
breath, I’ve got too may other things on my plate as it
is. Sorry :frowning:

          But if someone wants to dig in, I'll try to help if you

have specific questions.

https://github.com/matplotlib/matplotlib/pull/3421

Could you please try and change the backend_wx.py.
In the method ‘FigureCanvasWx.gui_repaint’ replace this:
drawDC.DrawBitmap(self.bitmap, 0, 0)
with this:
drawDC.Clear()
drawDC.DrawBitmap(self.bitmap, 0, 0)
Werner

···

On 9/3/2014 14:32, wrote:

goofcc@gmail.com

      It is this effect, scaling, when the

form is not refreshed。

        在 2014年9月2日星期二UTC+8下午9时46分24秒,写道:

goo...@gmail.com

            matplotlib runs perfectly on Windows, but

is not compatible with Mac OS X, cannot
be scaled operation, does
not refresh gui,have encountered this problem?

https://github.com/matplotlib/matplotlib/blob/master/examples/user_interfaces/embedding_in_wx5.py

                  Environment is: wxPython3.0 + matplotlib1.4 + Mac

OS X10.8