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

Use PyQt5 as default API #2879

Merged
merged 2 commits into from
Dec 28, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 15 additions & 23 deletions spyderlib/qt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,24 @@

import os

os.environ.setdefault('QT_API', 'pyqt')
os.environ.setdefault('QT_API', 'pyqt5')
assert os.environ['QT_API'] in ('pyqt5', 'pyqt', 'pyside')

API = os.environ['QT_API']
API_NAME = {'pyqt5': 'PyQt5', 'pyqt': 'PyQt4', 'pyside': 'PySide'}[API]

is_old_pyqt = is_pyqt46 = False
PYQT5 = True

if API == 'pyqt5':
try:
from PyQt5.QtCore import PYQT_VERSION_STR as __version__
from PyQt5 import uic # analysis:ignore
except ImportError:
PYQT5 = False
API = os.environ['QT_API'] = 'pyqt'
API_NAME = 'PyQt4'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should set PYQT5 = False here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, it's easier to read and understand.

if API == 'pyqt':
# Spyder 2.3 is compatible with both #1 and #2 PyQt API,
# but to avoid issues with IPython and other Qt plugins
Expand All @@ -36,16 +48,8 @@

from PyQt4.QtCore import PYQT_VERSION_STR as __version__ # analysis:ignore
except ImportError:
# Trying PyQt5 before switching to PySide (at this point, PyQt4 may
# not be installed but PyQt5 or Pyside could still be if the QT_API
# environment variable hasn't been set-up)
try:
import PyQt5 # analysis:ignore
API = os.environ['QT_API'] = 'pyqt5'
API_NAME = 'PyQt5'
except ImportError:
API = os.environ['QT_API'] = 'pyside'
API_NAME = 'PySide'
API = os.environ['QT_API'] = 'pyside'
API_NAME = 'PySide'
else:
is_old_pyqt = __version__.startswith(('4.4', '4.5', '4.6', '4.7'))
is_pyqt46 = __version__.startswith('4.6')
Expand All @@ -56,20 +60,8 @@
pass
from PyQt4 import uic # analysis:ignore

PYQT5 = False
if API == 'pyqt5':
try:
from PyQt5.QtCore import PYQT_VERSION_STR as __version__
from PyQt5 import uic # analysis:ignore
PYQT5 = True
is_old_pyqt = is_pyqt46 = False
except ImportError:
pass

if API == 'pyside':
try:
from PySide import __version__ # analysis:ignore
except ImportError:
raise ImportError("Spyder requires PySide or PyQt to be installed")
else:
is_old_pyqt = is_pyqt46 = False