-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix wx_compat code for wxPython >= 4.0.0b2 #9187
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
Fix wx_compat code for wxPython >= 4.0.0b2 #9187
Conversation
lib/matplotlib/backends/wx_compat.py
Outdated
longHelpString=tooltip_text, | ||
kind=kind) | ||
|
||
if LooseVersion(wx.VERSION_STRING) >= LooseVersion("4.0.0b2"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would all of these work for the old wx as well? In other words, could we just drop the code in the else clause if we decide not to support the beta versions of phoenix (once the actual release of phoenix comes)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. At that point I think there could also be a bit more simplification for Classic wxPython support as well, since the new AddTool
signature matches the signature for DoAddTool
in Classic. So it would then boil down to just a difference in method names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change the PR accordingly?
Changes to use DoAddTool in Classic, which is the same as AddTool in Phoenix. Includes a note about even more possible simplification when support for all pre-release builds of Phoenix is dropped.
Additional refactoring implemented, along with a note about what can be removed in the future. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the very clear PR.
@RobinD42 Actually you need to fix a minor style nitpick (https://travis-ci.org/matplotlib/matplotlib/jobs/275984202#L3031). You can just drop the second call to LooseVersion, as the first one will implicitly coerce the second one to LooseVersion as well when doing the comparison. |
@RobinD42 Do you mind if I push commits to your branch? |
Hello everyone! I am a CS grad student who is very new to Python and to Github (crazy, I know). I am using wxPython and matplotlib for a research project, and seem to be getting the error described above. Currently, I have: I am still receiving the error. What am I doing wrong? |
Feel free to do so. |
When you say,
Where did you get it from? Does it include the changes from this PR? |
Says it was updated 21 hours ago; I assume that's the most recent. |
@krischer, I guess the next step would be to ensure that the file you moved into place is actually the one being imported, and not some other one that may be elsewhere on your system. There are various things that can be checked, for example you can import the module in your code and then check its
|
@RobinD42 I think you pinged the wrong person ;) |
Oops, that should have been @krlsmnk of course. Too many kr's here I guess. 😉 |
The old url only points to sdists now, which caused travis to try building wxpython itself, with no success. Wheels are now at the new url.
Thanks @RobinD42 ! |
@meeseeksdev backport to v2.1.x |
<!--Thank you so much for your PR! To help us review, fill out the form to the best of your ability. Please make use of the development guide at https://matplotlib.org/devdocs/devel/index.html--> <!--Provide a general summary of your changes in the title above, for example "Raises ValueError on Non-Numeric Input to set_xlim". Please avoid non-descriptive titles such as "Addresses issue 8576".--> <!--If you are able to do so, please do not create the PR out of master, but out of a separate branch. See https://matplotlib.org/devel/gitwash/development_workflow.html for instructions.--> PR Summary Some arg names in `wx.ToolBar.AddTool` are being changed in order to be more consistent with other tool methods, and also for better compatibility with Classic. This change trips up the code in `wx_compat` since it is using keyword args when calling `AddTool`. This PR is one possible fix. Another would be to not use the keyword args and just use positional args since the order and types have not changed. <!--If it fixes an open issue, please link to the issue here.--> See: wxWidgets/Phoenix#527 PR Checklist - [ ] Has Pytest style unit tests - [x] Code is PEP 8 compliant - [ ] New features are documented, with examples if plot related - [ ] Documentation is sphinx and numpydoc compliant - [ ] Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there) - [ ] Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way <!--We understand that PRs can sometimes be overwhelming, especially as the reviews start coming in. Please let us know if the reviews are unclear or the recommended next step seems overly demanding , or if you would like help in addressing a reviewer's comments. And please ping us if you've been waiting too long to hear back on your PR.-->
Backport PR #9187 on branch v2.1.x
File "C:\Anaconda2\lib\site-packages\matplotlib\pyplot.py", line 535, in figure Removing LooseVersion solved my problem. Not sure what had happened to my anaconda. |
Ah the joys of Py2. |
So do I import wx_compat in addition to both Matplotlib and wx, or as a replacement for one of them? I currently commented out my wx import, and imported: and app = wx.App(False) |
…にしたがってwx_compat.pyを修正してみたが上手くいかず。しかしバグの可能性が高い。
PR Summary
Some arg names in
wx.ToolBar.AddTool
are being changed in order to be more consistent with other tool methods, and also for better compatibility with Classic. This change trips up the code inwx_compat
since it is using keyword args when callingAddTool
. This PR is one possible fix. Another would be to not use the keyword args and just use positional args since the order and types have not changed.See: wxWidgets/Phoenix#527
PR Checklist