-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fixed PyQt5 detection without QT_API env var #2691
Conversation
When QT_API environment variable has not been set properly, which is safe to assume when using PyQt5 for the first time, importing the `spyderlib.qt` package will fail. This change allows PyQt5 to be imported and used if QT_API has not been set and if both PyQt4 and PySide packages are not installed.
@@ -57,6 +54,17 @@ | |||
API_NAME += (" (API v%d)" % sip.getapi('QString')) | |||
except AttributeError: | |||
pass | |||
from PyQt4 import uic # analysis:ignore |
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.
Why is this necessary now?
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.
The spyderlib.qt
package was wrote not only for Spyder but also for other libraries* (guidata
, winpython
and now python-qwt
). Adding the line from PyQt4 import uic
here will simply allow to import the uic
module with from spyderlib.qt import uic
, that's all. FYI, the uic
module is used to run GUI built with the help of QtDesigner (see this example).
* guidata.qt
, winpython.qt
and qwt.qt
are extensive copies of spyderlib.qt
.
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.
Ok, no problem. I just wanted to know why you decided to add it given that we don't use QtDesigner in Spyder.
By the way, we're planning to move to use qtpy (one of the Spyder org projects) as our Qt shim.
I think that would help your projects too, to avoid copy/pasting the Spyder shim around, and to have everything consolidated in one place.
Thanks a lot @PierreRaybaut. Everything seems fine except for the two comments I made :-) |
Fixed PyQt5 detection without QT_API env var
@PierreRaybaut, just a simple recommendation for next time: please use your own fork of Spyder to create pull requests, instead of creating branches in the main repo. The thing is those branches are propagated to all people that pull regularly from Github (like our other core developers :-) Of course, you're more than welcome to submit directly to |
@ccordoba12 Sorry for the inconvenience, I'm such a newbie with |
No problem :-) Glad to have you back! |
When QT_API environment variable has not been set properly, which is safe to assume when using PyQt5 for the first time, importing the
spyderlib.qt
package will fail. This change allows PyQt5 to be imported and used if QT_API has not been set and if both PyQt4 and PySide packages are not installed.