Skip to content

Commit 8d53ebf

Browse files
authored
Merge pull request #10363 from BrennanGit/fix-AddTool-for-wxPy4.0.0
Fix to allow both old and new style wx versions
2 parents db1cde0 + da57cd7 commit 8d53ebf

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

@@ -23,8 +23,13 @@
2323
except ImportError:
2424
raise ImportError(missingwx)
2525

26+
try:
27+
wx_version = StrictVersion(wx.VERSION_STRING)
28+
except ValueError:
29+
wx_version = LooseVersion(wx.VERSION_STRING)
30+
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)