Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bf2b673

Browse files
authored
Fix to allow both old and new style wx versions
1 parent ecf89ee commit bf2b673

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/matplotlib/backends/wx_compat.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
unicode_literals)
1212

1313
import six
14-
from distutils.version import StrictVersion
14+
from distutils.version import StrictVersion, LooseVersion
1515

1616
missingwx = "Matplotlib backend_wx and backend_wxagg require wxPython>=2.9"
1717

@@ -22,9 +22,14 @@
2222
is_phoenix = 'phoenix' in wx.PlatformInfo
2323
except ImportError:
2424
raise ImportError(missingwx)
25+
26+
try:
27+
wx_version = StrictVersion(wx.VERSIONSTRING)
28+
except ValueError:
29+
wx_version = LooseVersion(wx.VERSIONSTRING)
2530

2631
# Ensure we have the correct version imported
27-
if StrictVersion(wx.VERSION_STRING) < StrictVersion("2.9"):
32+
if wx_version < str("2.9"):
2833
raise ImportError(missingwx)
2934

3035
if is_phoenix:
@@ -152,7 +157,7 @@ def _AddTool(parent, wx_ids, text, bmp, tooltip_text):
152157
else:
153158
add_tool = parent.DoAddTool
154159

155-
if not is_phoenix or StrictVersion(wx.VERSION_STRING) >= str("4.0.0b2"):
160+
if not is_phoenix or wx_version >= str("4.0.0b2"):
156161
# NOTE: when support for Phoenix prior to 4.0.0b2 is dropped then
157162
# all that is needed is this clause, and the if and else clause can
158163
# be removed.

0 commit comments

Comments
 (0)