diff --git a/.travis.yml b/.travis.yml index cd19f60b7de1..8cd801b42ce3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -124,7 +124,7 @@ install: echo 'PyQt5 is available' || echo 'PyQt5 is not available' pip install -U --pre \ - -f https://wxpython.org/Phoenix/release-extras/linux/gtk3/ubuntu-14.04 \ + -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-14.04 \ wxPython && python -c 'import wx' && echo 'wxPython is available' || diff --git a/lib/matplotlib/backends/wx_compat.py b/lib/matplotlib/backends/wx_compat.py index 0d2bd409ed86..137af577d881 100644 --- a/lib/matplotlib/backends/wx_compat.py +++ b/lib/matplotlib/backends/wx_compat.py @@ -139,24 +139,36 @@ StockCursor = wx.StockCursor +# wxPython Classic's DoAddTool has become AddTool in Phoenix. Otherwise +# they are the same, except for early betas and prerelease builds of +# Phoenix. This function provides a shim that does the RightThing based on +# which wxPython is in use. def _AddTool(parent, wx_ids, text, bmp, tooltip_text): + if text in ['Pan', 'Zoom']: + kind = wx.ITEM_CHECK + else: + kind = wx.ITEM_NORMAL if is_phoenix: - if text in ['Pan', 'Zoom']: - kind = wx.ITEM_CHECK - else: - kind = wx.ITEM_NORMAL - parent.AddTool(wx_ids[text], label=text, - bitmap=bmp, - bmpDisabled=wx.NullBitmap, - shortHelpString=text, - longHelpString=tooltip_text, - kind=kind) + add_tool = parent.AddTool + else: + add_tool = parent.DoAddTool + + if not is_phoenix or LooseVersion(wx.VERSION_STRING) >= "4.0.0b2": + # NOTE: when support for Phoenix prior to 4.0.0b2 is dropped then + # all that is needed is this clause, and the if and else clause can + # be removed. + kwargs = dict(label=text, + bitmap=bmp, + bmpDisabled=wx.NullBitmap, + shortHelp=text, + longHelp=tooltip_text, + kind=kind) else: - if text in ['Pan', 'Zoom']: - parent.AddCheckTool( - wx_ids[text], - bmp, - shortHelp=text, - longHelp=tooltip_text) - else: - parent.AddSimpleTool(wx_ids[text], bmp, text, tooltip_text) + kwargs = dict(label=text, + bitmap=bmp, + bmpDisabled=wx.NullBitmap, + shortHelpString=text, + longHelpString=tooltip_text, + kind=kind) + + return add_tool(wx_ids[text], **kwargs)