Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get wx backends and examples compitable with Phoenix #2803

Closed
wants to merge 126 commits into from

Conversation

wernerfb
Copy link
Contributor

No description provided.

@wernerfb wernerfb mentioned this pull request Feb 11, 2014
@wernerfb
Copy link
Contributor Author

Just FYI, wxPython Phoenix will only support Py 2.7 and 3.3+

@@ -667,8 +667,6 @@ class FigureCanvasWx(FigureCanvasBase, wx.Panel):
wx.WXK_DELETE : 'delete',
wx.WXK_HOME : 'home',
wx.WXK_END : 'end',
wx.WXK_PRIOR : 'pageup',
wx.WXK_NEXT : 'pagedown',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove these (and the same a few blocks down)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tacaswell
Copy link
Member

Is it better to patch over all of the api changes in place or to create a compat layer like we do for qt4?

Unless you feel very strongly that this needs to go into 1.4.0, I am going to tag this 1.4.x

@tacaswell tacaswell added this to the v1.4.x milestone Feb 19, 2014
@wernerfb
Copy link
Contributor Author

Except the WXK things I used a 'phoenix' version check, as these have been gone for a long time I didn't do it, but I can add it.

The changes run with current wxPython (2.8x), so no change for current users, except maybe the above if someone used those.

Phoenix is the only wxPython version which will be Python 3 compatible, so the sooner it gets into matplotlib the sooner people could start testing wxPython and matplotlib on Py3.3+.

I am only preparing my stuff for Py3.3 that is why I did this work but there is no urgency for me.

@tacaswell tacaswell modified the milestones: v1.4.x, v1.4.0 Feb 19, 2014
@nepix32
Copy link
Contributor

nepix32 commented Apr 23, 2014

@tacaswell What do you mean with qt4 compat layer?
Like in the file https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backends/qt4_compat.py?

So you propose something like a wx_compat.py like the following:

e.g. no more EmptyBitmap functions:

import wx
# where do we live
is_classic = False if 'phoenix' in wx.PlatformInfo else True

if is_classic:
    _EmptyBitmap = wx.EmptyBitmap
    _BitmapFromBufferRGBA = wx.BitmapFromBufferRGBA
    # ...
else:
    _EmptyBitmap = wx.Bitmap
    _BitmapFromBufferRGBA = wx.Bitmap.FromBufferRGBA
   # ...

How about more tricky cases like drawDC.BeginDrawing()/EndDrawing()? This could be something nice for a context manager or a decorator.

class _drawdccontext(object):
    def __init__(self, drawdc):
        self.drawdc = drawdc
    def __enter__(self):
        if is_classic:
            self.drawdc.BeginDrawing()
    def __exit__(self, type, value, traceback):
        if is_classic:
              self.drawdc.EndDrawing() 
# ...

    def gui_repaint(self, drawDC=None):
# ...
           with _drawdccontext(drawDC):
                drawDC.DrawBitmap(self.bitmap, 0, 0)
# instead of
           if 'phoenix' in wx.PlatformInfo:
               drawDC.DrawBitmap(self.bitmap, 0, 0)
           else:       
               drawDC.BeginDrawing()
               drawDC.DrawBitmap(self.bitmap, 0, 0)
               drawDC.EndDrawing()

Do I understand this correctly?

With best regards,

@efiring
Copy link
Member

efiring commented Apr 23, 2014

I haven't looked closely at all, so I might be missing something, but here is my reaction:

A context manager looks like overkill. I think a compatibility layer approach would look like this:

is_classic = 'phoenix' not in wx.PlatformInfo

if is_classic:
    def draw_bitmap(drawDC, *args):
        drawDC.BeginDrawing()
        drawDC.DrawBitmap(*args)
        drawDC.EndDrawing()
else:
    def draw_bitmap(DrawDC, *args):
        DrawDC.DrawBitmap(*args)

along with your other compatibility definitions. I would probably leave out the underscores, and then do

import wx_compat as compat
# stuff...
    compat.draw_bitmap(self.bitmap, 0, 0)

This would be analogous to using six for 2-3 compatibility. It makes it easy to see where the compatibility substitutions are.

@nepix32
Copy link
Contributor

nepix32 commented Apr 23, 2014

@efiring : Went for the context manager because there is another occurrence of a longer-spanning BeginDrawing/EndDrawing block in draw_rubberband (see wernerfb@cbb1d4c#diff-19c3295dfd86eed49da406f5e5296055L1740).

For this the rather long code block had to be pulled out of context. But maybe there is a better solution for this than a contextmanager. Or an even easier to understand one like the one done by @wernerfb .

Just trying to find the best tool for the job.

@nepix32
Copy link
Contributor

nepix32 commented Apr 24, 2014

As @RobinD42 (wxPython maintainer) pointed out in wxpython-users https://groups.google.com/forum/#!topic/wxpython-users/4NRdfJr79Gk, calls to drawDC.BeginDrawing()/EndDrawing() have never been more as C++ stubs and can be safely removed.

So much for the fancy decorating …

tacaswell and others added 27 commits August 15, 2014 17:06
DOC : added folders for api_changes and whats_new
There is no intentional support for np.matrix or
pandas data objects as input to plotting functions.
DOC : add note about np.matrix and pandas objects
BUG: Fixes custom path marker sizing

Closes matplotlib#1980

Closes
Filter warnings in rcparams test (and others)
…ings

Cast to integer to get rid of numpy warning
BUG : Don't clear glyphs if face never made
Catch warning thrown in Mollweide projection.
- only use wxversion in Py2
- remove BeginDrawing/EndDrawing
- make it work in Py2.7 and Py3.4 with wxPython 2.8.12, 2.9.5 and 3.0.2Phoenix
- make it work on Py2.7 with wxPython 2.8.12, 2.9.5 and 3.0.2Phoenix
- make it work on Py3.4 with 3.0.2Phoenix
…no attribute 'ProcessIdle'

- use wxversion only in Py2
- make it work on Py2.7 with wxPython 2.8.12, 2.9.5 and 3.0.2Phoenix
- make it work on Py3.4 with 3.0.2Phoenix
… wxPythonPhoenix

Conflicts:
	examples/user_interfaces/embedding_in_wx2.py
	examples/user_interfaces/embedding_in_wx4.py
	examples/user_interfaces/embedding_in_wx5.py
	examples/user_interfaces/fourier_demo_wx.py
	lib/matplotlib/backends/backend_wx.py
	lib/matplotlib/backends/backend_wxagg.py
@wernerfb
Copy link
Contributor Author

Will redo this on current master (1.4.0)

@wernerfb wernerfb closed this Aug 27, 2014
@tacaswell
Copy link
Member

@wernerfb PRs track branches, not commits. You can just force-push to this branch to clean this up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet