Skip to content

Commit

Permalink
Qt shim: Remove unneeded debug function and clarify a comment
Browse files Browse the repository at this point in the history
  • Loading branch information
ccordoba12 committed Dec 8, 2014
1 parent 884e74b commit 4a50123
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions spyderlib/qt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,34 @@

import os


def debug(msg):
# lightweight debug function
#print(msg)
pass


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

API = os.environ['QT_API']
API_NAME = None

if API == 'pyqt':
# Spyder 2.2 is compatible with both #1 and #2 PyQt API,
# Spyder 2.3 is compatible with both #1 and #2 PyQt API,
# but to avoid issues with IPython and other Qt plugins
# we choose to support only API #2 for 2.3+
# we choose to support only API #2 for 2.4+
try:
import sip
sip.setapi('QString', 2)
sip.setapi('QVariant', 2)
except ImportError:
debug('qt: PyQt4 is not found. Fallback to PySide API')
print('qt: PyQt4 is not found. Fallback to PySide API')
API = os.environ['QT_API'] = 'pyside'
except AttributeError:
# PyQt < 4.6. Fallback to API #1
debug('qt: Fallback to PyQt4 API #1')
print('qt: Fallback to PyQt4 API #1')
API = os.environ['QT_API'] = 'pyqtv1'

if API in ('pyqtv1', 'pyqt'):
try:
from PyQt4.QtCore import PYQT_VERSION_STR as __version__
except ImportError:
# No PyQt4. Fallback to PySide
debug('qt: Fallback to PySide API')
print('qt: Fallback to PySide API')
API = os.environ['QT_API'] = 'pyside'
else:
is_old_pyqt = __version__.startswith(('4.4', '4.5', '4.6', '4.7'))
Expand Down

0 comments on commit 4a50123

Please sign in to comment.