Skip to content
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

Merged
merged 1 commit into from
Sep 14, 2015

Conversation

PierreRaybaut
Copy link
Contributor

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.

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
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

@ccordoba12
Copy link
Member

Thanks a lot @PierreRaybaut. Everything seems fine except for the two comments I made :-)

@ccordoba12 ccordoba12 added this to the v3.0 milestone Sep 13, 2015
ccordoba12 added a commit that referenced this pull request Sep 14, 2015
Fixed PyQt5 detection without QT_API env var
@ccordoba12 ccordoba12 merged commit b1d9780 into master Sep 14, 2015
@ccordoba12 ccordoba12 deleted the PyQt5_detection_issue branch September 14, 2015 15:05
@ccordoba12
Copy link
Member

@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 master if you prefer to do so :-)

@PierreRaybaut
Copy link
Contributor Author

@ccordoba12 Sorry for the inconvenience, I'm such a newbie with git and GitHub. I'll remember it for next time. Keep up the good work.

@ccordoba12
Copy link
Member

No problem :-) Glad to have you back!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants