diff options
Diffstat (limited to 'silx/gui/qt/_qt.py')
-rw-r--r-- | silx/gui/qt/_qt.py | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/silx/gui/qt/_qt.py b/silx/gui/qt/_qt.py index 6bf7d93..a4b9007 100644 --- a/silx/gui/qt/_qt.py +++ b/silx/gui/qt/_qt.py @@ -22,21 +22,7 @@ # THE SOFTWARE. # # ###########################################################################*/ -"""Common wrapper over Python Qt bindings: - -- `PyQt5 <http://pyqt.sourceforge.net/Docs/PyQt5/>`_, -- `PyQt4 <http://pyqt.sourceforge.net/Docs/PyQt4/>`_ or -- `PySide <http://www.pyside.org>`_. - -If a Qt binding is already loaded, it will use it, otherwise the different -Qt bindings are tried in this order: PySide2, PyQt4, PySide, PyQt5. - -The name of the loaded Qt binding is stored in the BINDING variable. - -For an alternative solution providing a structured namespace, -see `qtpy <https://pypi.python.org/pypi/QtPy/>`_ which -provides the namespace of PyQt5 over PyQt4, PySide and PySide2. -""" +"""Load Qt binding""" __authors__ = ["V.A. Sole"] __license__ = "MIT" @@ -47,15 +33,17 @@ import logging import sys import traceback +from ...utils.deprecation import deprecated_warning + _logger = logging.getLogger(__name__) BINDING = None -"""The name of the Qt binding in use: PyQt5, 'PyQt4, PySide2 or PySide.""" +"""The name of the Qt binding in use: PyQt5, PyQt4 or PySide2.""" QtBinding = None # noqa -"""The Qt binding module in use: PyQt5, PyQt4, PySide2 or PySide.""" +"""The Qt binding module in use: PyQt5, PyQt4 or PySide2.""" HAS_SVG = False """True if Qt provides support for Scalable Vector Graphics (QtSVG).""" @@ -84,17 +72,17 @@ else: # Then try Qt bindings import PyQt4 # noqa except ImportError: try: - import PySide # noqa + import PySide2 # noqa except ImportError: try: - import PySide2 # noqa + import PySide # noqa except ImportError: raise ImportError( 'No Qt wrapper found. Install PyQt5, PyQt4 or PySide2.') else: - BINDING = 'PySide2' + BINDING = 'PySide' else: - BINDING = 'PySide' + BINDING = 'PySide2' else: BINDING = 'PyQt4' else: @@ -103,6 +91,9 @@ else: # Then try Qt bindings if BINDING == 'PyQt4': _logger.debug('Using PyQt4 bindings') + deprecated_warning("Qt Binding", "PyQt4", + replacement='PyQt5', + since_version='0.9.0') if sys.version_info < (3, ): try: @@ -110,6 +101,11 @@ if BINDING == 'PyQt4': sip.setapi("QString", 2) sip.setapi("QVariant", 2) + sip.setapi('QDate', 2) + sip.setapi('QDateTime', 2) + sip.setapi('QTextStream', 2) + sip.setapi('QTime', 2) + sip.setapi('QUrl', 2) except: _logger.warning("Cannot set sip API") @@ -144,6 +140,9 @@ if BINDING == 'PyQt4': elif BINDING == 'PySide': _logger.debug('Using PySide bindings') + deprecated_warning("Qt Binding", "PySide", + replacement='PySide2', + since_version='0.9.0') import PySide as QtBinding # noqa @@ -238,7 +237,7 @@ elif BINDING == 'PySide2': HAS_SVG = True # Import loadUi wrapper for PySide2 - # TODO from ._pyside_dynamic import loadUi # noqa + from ._pyside_dynamic import loadUi # noqa pyqtSignal = Signal |