Python PySide.__version__() Examples

The following are 30 code examples of PySide.__version__(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PySide , or try the search function .
Example #1
Source File: qt_compat.py    From twitter-stock-recommendation with MIT License 32 votes vote down vote up
def _setup_pyqt5():
    global QtCore, QtGui, QtWidgets, __version__, is_pyqt5, _getSaveFileName

    if QT_API == QT_API_PYQT5:
        from PyQt5 import QtCore, QtGui, QtWidgets
        __version__ = QtCore.PYQT_VERSION_STR
        QtCore.Signal = QtCore.pyqtSignal
        QtCore.Slot = QtCore.pyqtSlot
        QtCore.Property = QtCore.pyqtProperty
    elif QT_API == QT_API_PYSIDE2:
        from PySide2 import QtCore, QtGui, QtWidgets, __version__
    else:
        raise ValueError("Unexpected value for the 'backend.qt5' rcparam")
    _getSaveFileName = QtWidgets.QFileDialog.getSaveFileName

    def is_pyqt5():
        return True 
Example #2
Source File: Qt.py    From dm2skin with The Unlicense 6 votes vote down vote up
def _pyside2():
    """Initialise PySide2

    These functions serve to test the existence of a binding
    along with set it up in such a way that it aligns with
    the final step; adding members from the original binding
    to Qt.py

    """

    import PySide2 as module
    _setup(module, ["QtUiTools"])

    Qt.__binding_version__ = module.__version__

    try:
        import shiboken2
        Qt.QtCompat.wrapInstance = (
            lambda ptr, base=None: _wrapinstance(
                shiboken2.wrapInstance, ptr, base)
        )
        Qt.QtCompat.getCppPointer = lambda object: \
            shiboken2.getCppPointer(object)[0]

    except ImportError:
        pass  # Optional

    if hasattr(Qt, "_QtUiTools"):
        Qt.QtCompat.loadUi = _loadUi

    if hasattr(Qt, "_QtCore"):
        Qt.__qt_version__ = Qt._QtCore.qVersion()
        Qt.QtCompat.translate = Qt._QtCore.QCoreApplication.translate

    if hasattr(Qt, "_QtWidgets"):
        Qt.QtCompat.setSectionResizeMode = \
            Qt._QtWidgets.QHeaderView.setSectionResizeMode

    _reassign_misplaced_members("pyside2") 
Example #3
Source File: Qt.py    From pyblish-maya with GNU Lesser General Public License v3.0 6 votes vote down vote up
def _maintain_backwards_compatibility(binding):
    """Add members found in prior versions up till the next major release

    These members are to be considered deprecated. When a new major
    release is made, these members are removed.

    """

    for member in ("__binding__",
                   "__binding_version__",
                   "__qt_version__",
                   "__added__",
                   "__remapped__",
                   "__modified__",
                   "convert",
                   "load_ui",
                   "translate"):
        setattr(binding, member, getattr(self, member))
        self.__added__.append(member)

    setattr(binding, "__wrapper_version__", self.__version__)
    self.__added__.append("__wrapper_version__") 
Example #4
Source File: Qt.py    From NukeToolSet with MIT License 6 votes vote down vote up
def _pyside2():
    """Initialise PySide2

    These functions serve to test the existence of a binding
    along with set it up in such a way that it aligns with
    the final step; adding members from the original binding
    to Qt.py

    """

    import PySide2 as module
    _setup(module, ["QtUiTools"])

    Qt.__binding_version__ = module.__version__

    try:
        import shiboken2
        Qt.QtCompat.wrapInstance = (
            lambda ptr, base=None: _wrapinstance(
                shiboken2.wrapInstance, ptr, base)
        )
        Qt.QtCompat.getCppPointer = lambda object: \
            shiboken2.getCppPointer(object)[0]

    except ImportError:
        pass  # Optional

    if hasattr(Qt, "_QtUiTools"):
        Qt.QtCompat.loadUi = _loadUi

    if hasattr(Qt, "_QtCore"):
        Qt.__qt_version__ = Qt._QtCore.qVersion()
        Qt.QtCompat.translate = Qt._QtCore.QCoreApplication.translate

    if hasattr(Qt, "_QtWidgets"):
        Qt.QtCompat.setSectionResizeMode = \
            Qt._QtWidgets.QHeaderView.setSectionResizeMode

    _reassign_misplaced_members("pyside2") 
Example #5
Source File: Qt.py    From pyblish-maya with GNU Lesser General Public License v3.0 6 votes vote down vote up
def _pyside2():
    import PySide2
    from PySide2 import QtGui, QtWidgets, QtCore, QtUiTools

    _remap(QtCore, "QStringListModel", QtGui.QStringListModel)

    _add(QtCompat, "__binding__", PySide2.__name__)
    _add(QtCompat, "__binding_version__", PySide2.__version__)
    _add(QtCompat, "__qt_version__", PySide2.QtCore.qVersion())
    _add(QtCompat, "load_ui", lambda fname: QtUiTools.QUiLoader().load(fname))

    _add(QtCompat, "setSectionResizeMode",
         QtWidgets.QHeaderView.setSectionResizeMode)

    _add(QtCompat, "translate", QtCore.QCoreApplication.translate)

    _maintain_backwards_compatibility(PySide2)

    return PySide2 
Example #6
Source File: Qt.py    From mgear_dist with MIT License 5 votes vote down vote up
def _pyside():
    """Initialise PySide"""

    import PySide as module
    extras = ["QtUiTools"]
    try:
        try:
            # Before merge of PySide and shiboken
            import shiboken
        except ImportError:
            # After merge of PySide and shiboken, May 2017
            from PySide import shiboken
        extras.append("shiboken")
    except ImportError:
        pass

    _setup(module, extras)
    Qt.__binding_version__ = module.__version__

    if hasattr(Qt, "_shiboken"):
        Qt.QtCompat.wrapInstance = _wrapinstance
        Qt.QtCompat.getCppPointer = _getcpppointer
        Qt.QtCompat.delete = shiboken.delete

    if hasattr(Qt, "_QtUiTools"):
        Qt.QtCompat.loadUi = _loadUi

    if hasattr(Qt, "_QtGui"):
        setattr(Qt, "QtWidgets", _new_module("QtWidgets"))
        setattr(Qt, "_QtWidgets", Qt._QtGui)
        if hasattr(Qt._QtGui, "QX11Info"):
            setattr(Qt, "QtX11Extras", _new_module("QtX11Extras"))
            Qt.QtX11Extras.QX11Info = Qt._QtGui.QX11Info

        Qt.QtCompat.setSectionResizeMode = Qt._QtGui.QHeaderView.setResizeMode

    if hasattr(Qt, "_QtCore"):
        Qt.__qt_version__ = Qt._QtCore.qVersion()

    _reassign_misplaced_members("PySide")
    _build_compatibility_members("PySide") 
Example #7
Source File: Qt.py    From MayaDev with MIT License 5 votes vote down vote up
def _pyside():
    """Initialise PySide"""

    import PySide as module
    extras = ["QtUiTools"]
    try:
        try:
            # Before merge of PySide and shiboken
            import shiboken
        except ImportError:
            # After merge of PySide and shiboken, May 2017
            from PySide import shiboken
        extras.append("shiboken")
    except ImportError:
        pass

    _setup(module, extras)
    Qt.__binding_version__ = module.__version__

    if hasattr(Qt, "_shiboken"):
        Qt.QtCompat.wrapInstance = _wrapinstance
        Qt.QtCompat.getCppPointer = _getcpppointer
        Qt.QtCompat.delete = shiboken.delete

    if hasattr(Qt, "_QtUiTools"):
        Qt.QtCompat.loadUi = _loadUi

    if hasattr(Qt, "_QtGui"):
        setattr(Qt, "QtWidgets", _new_module("QtWidgets"))
        setattr(Qt, "_QtWidgets", Qt._QtGui)
        if hasattr(Qt._QtGui, "QX11Info"):
            setattr(Qt, "QtX11Extras", _new_module("QtX11Extras"))
            Qt.QtX11Extras.QX11Info = Qt._QtGui.QX11Info

        Qt.QtCompat.setSectionResizeMode = Qt._QtGui.QHeaderView.setResizeMode

    if hasattr(Qt, "_QtCore"):
        Qt.__qt_version__ = Qt._QtCore.qVersion()

    _reassign_misplaced_members("PySide")
    _build_compatibility_members("PySide") 
Example #8
Source File: qt_loaders.py    From pySINDy with MIT License 5 votes vote down vote up
def has_binding(api):
    """Safely check for PyQt4/5, PySide or PySide2, without importing
       submodules

    Supports Python <= 3.3

       Parameters
       ----------
       api : str [ 'pyqtv1' | 'pyqt' | 'pyqt5' | 'pyside' | 'pyside2' | 'pyqtdefault']
            Which module to check for

       Returns
       -------
       True if the relevant module appears to be importable
    """
    # we can't import an incomplete pyside and pyqt4
    # this will cause a crash in sip (#1431)
    # check for complete presence before importing
    module_name = api_to_module[api]

    import imp
    try:
        #importing top level PyQt4/PySide module is ok...
        mod = __import__(module_name)
        #...importing submodules is not
        imp.find_module('QtCore', list(mod.__path__))
        imp.find_module('QtGui', list(mod.__path__))
        imp.find_module('QtSvg', list(mod.__path__))
        if api == QT_API_PYQT5 or api == QT_API_PYSIDE2:
            # QT5 requires QtWidgets too
            imp.find_module('QtWidgets', list(mod.__path__))

        #we can also safely check PySide version
        if api == QT_API_PYSIDE:
            return check_version(mod.__version__, '1.0.3')
        else:
            return True
    except ImportError:
        return False 
Example #9
Source File: qt_loaders.py    From pySINDy with MIT License 5 votes vote down vote up
def has_binding_new(api):
    """Safely check for PyQt4/5 or PySide, without importing submodules

    Supports Python >= 3.4

        Parameters
        ----------
        api : str [ 'pyqtv1' | 'pyqt' | 'pyqt5' | 'pyside' | 'pyqtdefault']
             Which module to check for

        Returns
        -------
        True if the relevant module appears to be importable
     """
    module_name = api_to_module[api]
    from importlib.util import find_spec

    required = ['QtCore', 'QtGui', 'QtSvg']
    if api in (QT_API_PYQT5, QT_API_PYSIDE2):
        # QT5 requires QtWidgets too
        required.append('QtWidgets')

    for submod in required:
        try:
            spec = find_spec('%s.%s' % (module_name, submod))
        except ImportError:
            # Package (e.g. PyQt5) not found
            return False
        else:
            if spec is None:
                # Submodule (e.g. PyQt5.QtCore) not found
                return False

    if api == QT_API_PYSIDE:
        # We can also safely check PySide version
        import PySide
        return check_version(PySide.__version__, '1.0.3')

    return True 
Example #10
Source File: Qt.py    From pyblish-lite with GNU Lesser General Public License v3.0 5 votes vote down vote up
def _pyside():
    """Initialise PySide"""

    import PySide as module
    extras = ["QtUiTools"]
    try:
        try:
            # Before merge of PySide and shiboken
            import shiboken
        except ImportError:
            # After merge of PySide and shiboken, May 2017
            from PySide import shiboken
        extras.append("shiboken")
    except ImportError:
        pass

    _setup(module, extras)
    Qt.__binding_version__ = module.__version__

    if hasattr(Qt, "_shiboken"):
        Qt.QtCompat.wrapInstance = _wrapinstance
        Qt.QtCompat.getCppPointer = _getcpppointer

    if hasattr(Qt, "_QtUiTools"):
        Qt.QtCompat.loadUi = _loadUi

    if hasattr(Qt, "_QtGui"):
        setattr(Qt, "QtWidgets", _new_module("QtWidgets"))
        setattr(Qt, "_QtWidgets", Qt._QtGui)
        if hasattr(Qt._QtGui, "QX11Info"):
            setattr(Qt, "QtX11Extras", _new_module("QtX11Extras"))
            Qt.QtX11Extras.QX11Info = Qt._QtGui.QX11Info

        Qt.QtCompat.setSectionResizeMode = Qt._QtGui.QHeaderView.setResizeMode

    if hasattr(Qt, "_QtCore"):
        Qt.__qt_version__ = Qt._QtCore.qVersion()

    _reassign_misplaced_members("PySide")
    _build_compatibility_members("PySide") 
Example #11
Source File: Qt.py    From core with MIT License 5 votes vote down vote up
def _pyside():
    """Initialise PySide"""

    import PySide as module
    extras = ["QtUiTools"]
    try:
        try:
            # Before merge of PySide and shiboken
            import shiboken
        except ImportError:
            # After merge of PySide and shiboken, May 2017
            from PySide import shiboken
        extras.append("shiboken")
    except ImportError:
        pass

    _setup(module, extras)
    Qt.__binding_version__ = module.__version__

    if hasattr(Qt, "_shiboken"):
        Qt.QtCompat.wrapInstance = _wrapinstance
        Qt.QtCompat.getCppPointer = _getcpppointer
        Qt.QtCompat.delete = shiboken.delete

    if hasattr(Qt, "_QtUiTools"):
        Qt.QtCompat.loadUi = _loadUi

    if hasattr(Qt, "_QtGui"):
        setattr(Qt, "QtWidgets", _new_module("QtWidgets"))
        setattr(Qt, "_QtWidgets", Qt._QtGui)
        if hasattr(Qt._QtGui, "QX11Info"):
            setattr(Qt, "QtX11Extras", _new_module("QtX11Extras"))
            Qt.QtX11Extras.QX11Info = Qt._QtGui.QX11Info

        Qt.QtCompat.setSectionResizeMode = Qt._QtGui.QHeaderView.setResizeMode

    if hasattr(Qt, "_QtCore"):
        Qt.__qt_version__ = Qt._QtCore.qVersion()

    _reassign_misplaced_members("PySide")
    _build_compatibility_members("PySide") 
Example #12
Source File: Qt.py    From nodegraph-pyqt with GNU General Public License v3.0 5 votes vote down vote up
def _pyside():
    """Initialise PySide"""

    import PySide as module
    extras = ["QtUiTools"]
    try:
        try:
            # Before merge of PySide and shiboken
            import shiboken
        except ImportError:
            # After merge of PySide and shiboken, May 2017
            from PySide import shiboken
        extras.append("shiboken")
    except ImportError:
        pass

    _setup(module, extras)
    Qt.__binding_version__ = module.__version__

    if hasattr(Qt, "_shiboken"):
        Qt.QtCompat.wrapInstance = _wrapinstance
        Qt.QtCompat.getCppPointer = _getcpppointer

    if hasattr(Qt, "_QtUiTools"):
        Qt.QtCompat.loadUi = _loadUi

    if hasattr(Qt, "_QtGui"):
        setattr(Qt, "QtWidgets", _new_module("QtWidgets"))
        setattr(Qt, "_QtWidgets", Qt._QtGui)
        if hasattr(Qt._QtGui, "QX11Info"):
            setattr(Qt, "QtX11Extras", _new_module("QtX11Extras"))
            Qt.QtX11Extras.QX11Info = Qt._QtGui.QX11Info

        Qt.QtCompat.setSectionResizeMode = Qt._QtGui.QHeaderView.setResizeMode

    if hasattr(Qt, "_QtCore"):
        Qt.__qt_version__ = Qt._QtCore.qVersion()

    _reassign_misplaced_members("PySide")
    _build_compatibility_members("PySide") 
Example #13
Source File: Qt.py    From P4VFX with MIT License 5 votes vote down vote up
def _pyside2():
    """Initialise PySide2

    These functions serve to test the existence of a binding
    along with set it up in such a way that it aligns with
    the final step; adding members from the original binding
    to Qt.py

    """

    import PySide2 as module
    _setup(module, ["QtUiTools"])

    Qt.__binding_version__ = module.__version__

    if hasattr(Qt, "_QtUiTools"):
        Qt.QtCompat.loadUi = lambda fname: \
            Qt._QtUiTools.QUiLoader().load(fname)

    if hasattr(Qt, "_QtGui") and hasattr(Qt, "_QtCore"):
        Qt.QtCore.QStringListModel = Qt._QtGui.QStringListModel

    if hasattr(Qt, "_QtWidgets"):
        Qt.QtCompat.setSectionResizeMode = \
            Qt._QtWidgets.QHeaderView.setSectionResizeMode

    if hasattr(Qt, "_QtCore"):
        Qt.__qt_version__ = Qt._QtCore.qVersion()
        Qt.QtCompat.translate = Qt._QtCore.QCoreApplication.translate

        Qt.QtCore.Property = Qt._QtCore.Property
        Qt.QtCore.Signal = Qt._QtCore.Signal
        Qt.QtCore.Slot = Qt._QtCore.Slot

        Qt.QtCore.QAbstractProxyModel = Qt._QtCore.QAbstractProxyModel
        Qt.QtCore.QSortFilterProxyModel = Qt._QtCore.QSortFilterProxyModel
        Qt.QtCore.QItemSelection = Qt._QtCore.QItemSelection
        Qt.QtCore.QItemSelectionRange = Qt._QtCore.QItemSelectionRange
        Qt.QtCore.QItemSelectionModel = Qt._QtCore.QItemSelectionModel 
Example #14
Source File: Qt.py    From pyblish-maya with GNU Lesser General Public License v3.0 5 votes vote down vote up
def _pyside():
    import PySide
    from PySide import QtGui, QtCore, QtUiTools

    _remap(PySide, "QtWidgets", QtGui)
    _remap(QtCore, "QSortFilterProxyModel", QtGui.QSortFilterProxyModel)
    _remap(QtCore, "QStringListModel", QtGui.QStringListModel)
    _remap(QtCore, "QItemSelection", QtGui.QItemSelection)
    _remap(QtCore, "QItemSelectionModel", QtGui.QItemSelectionModel)
    _remap(QtCore, "QAbstractProxyModel", QtGui.QAbstractProxyModel)

    try:
        from PySide import QtWebKit
        _remap(PySide, "QtWebKitWidgets", QtWebKit)
    except ImportError:
        "QtWebkit is optional in Qt, therefore might not be available"

    _add(QtCompat, "__binding__", PySide.__name__)
    _add(QtCompat, "__binding_version__", PySide.__version__)
    _add(QtCompat, "__qt_version__", PySide.QtCore.qVersion())
    _add(QtCompat, "load_ui", lambda fname: QtUiTools.QUiLoader().load(fname))
    _add(QtCompat, "setSectionResizeMode", QtGui.QHeaderView.setResizeMode)

    _add(QtCompat, "translate",
         lambda context, sourceText, disambiguation, n:
         QtCore.QCoreApplication.translate(context,
                                           sourceText,
                                           disambiguation,
                                           QtCore.QCoreApplication.CodecForTr,
                                           n))

    _maintain_backwards_compatibility(PySide)

    return PySide 
Example #15
Source File: Qt.py    From fossil with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _pyside():
    """Initialise PySide"""

    import PySide as module
    extras = ["QtUiTools"]
    try:
        try:
            # Before merge of PySide and shiboken
            import shiboken
        except ImportError:
            # After merge of PySide and shiboken, May 2017
            from PySide import shiboken
        extras.append("shiboken")
    except ImportError:
        pass

    _setup(module, extras)
    Qt.__binding_version__ = module.__version__

    if hasattr(Qt, "_shiboken"):
        Qt.QtCompat.wrapInstance = _wrapinstance
        Qt.QtCompat.getCppPointer = _getcpppointer
        Qt.QtCompat.delete = shiboken.delete

    if hasattr(Qt, "_QtUiTools"):
        Qt.QtCompat.loadUi = _loadUi

    if hasattr(Qt, "_QtGui"):
        setattr(Qt, "QtWidgets", _new_module("QtWidgets"))
        setattr(Qt, "_QtWidgets", Qt._QtGui)
        if hasattr(Qt._QtGui, "QX11Info"):
            setattr(Qt, "QtX11Extras", _new_module("QtX11Extras"))
            Qt.QtX11Extras.QX11Info = Qt._QtGui.QX11Info

        Qt.QtCompat.setSectionResizeMode = Qt._QtGui.QHeaderView.setResizeMode

    if hasattr(Qt, "_QtCore"):
        Qt.__qt_version__ = Qt._QtCore.qVersion()

    _reassign_misplaced_members("PySide")
    _build_compatibility_members("PySide") 
Example #16
Source File: Qt.py    From maya-capture-gui with MIT License 5 votes vote down vote up
def _pyside2():
    """Initialise PySide2

    These functions serve to test the existence of a binding
    along with set it up in such a way that it aligns with
    the final step; adding members from the original binding
    to Qt.py

    """

    import PySide2 as module
    _setup(module, ["QtUiTools"])

    Qt.__binding_version__ = module.__version__

    if hasattr(Qt, "_QtUiTools"):
        Qt.QtCompat.loadUi = lambda fname: \
            Qt._QtUiTools.QUiLoader().load(fname)

    if hasattr(Qt, "_QtGui") and hasattr(Qt, "_QtCore"):
        Qt.QtCore.QStringListModel = Qt._QtGui.QStringListModel

    if hasattr(Qt, "_QtWidgets"):
        Qt.QtCompat.setSectionResizeMode = \
            Qt._QtWidgets.QHeaderView.setSectionResizeMode

    if hasattr(Qt, "_QtCore"):
        Qt.__qt_version__ = Qt._QtCore.qVersion()
        Qt.QtCompat.translate = Qt._QtCore.QCoreApplication.translate

        Qt.QtCore.Property = Qt._QtCore.Property
        Qt.QtCore.Signal = Qt._QtCore.Signal
        Qt.QtCore.Slot = Qt._QtCore.Slot

        Qt.QtCore.QAbstractProxyModel = Qt._QtCore.QAbstractProxyModel
        Qt.QtCore.QSortFilterProxyModel = Qt._QtCore.QSortFilterProxyModel
        Qt.QtCore.QItemSelection = Qt._QtCore.QItemSelection
        Qt.QtCore.QItemSelectionRange = Qt._QtCore.QItemSelectionRange
        Qt.QtCore.QItemSelectionModel = Qt._QtCore.QItemSelectionModel 
Example #17
Source File: qt_loaders.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def has_binding_new(api):
    """Safely check for PyQt4/5 or PySide, without importing submodules

    Supports Python >= 3.4

        Parameters
        ----------
        api : str [ 'pyqtv1' | 'pyqt' | 'pyqt5' | 'pyside' | 'pyqtdefault']
             Which module to check for

        Returns
        -------
        True if the relevant module appears to be importable
     """
    module_name = api_to_module[api]
    from importlib.util import find_spec

    required = ['QtCore', 'QtGui', 'QtSvg']
    if api in (QT_API_PYQT5, QT_API_PYSIDE2):
        # QT5 requires QtWidgets too
        required.append('QtWidgets')

    for submod in required:
        try:
            spec = find_spec('%s.%s' % (module_name, submod))
        except ImportError:
            # Package (e.g. PyQt5) not found
            return False
        else:
            if spec is None:
                # Submodule (e.g. PyQt5.QtCore) not found
                return False

    if api == QT_API_PYSIDE:
        # We can also safely check PySide version
        import PySide
        return check_version(PySide.__version__, '1.0.3')

    return True 
Example #18
Source File: qt_loaders.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def has_binding(api):
    """Safely check for PyQt4/5, PySide or PySide2, without importing
       submodules

    Supports Python <= 3.3

       Parameters
       ----------
       api : str [ 'pyqtv1' | 'pyqt' | 'pyqt5' | 'pyside' | 'pyside2' | 'pyqtdefault']
            Which module to check for

       Returns
       -------
       True if the relevant module appears to be importable
    """
    # we can't import an incomplete pyside and pyqt4
    # this will cause a crash in sip (#1431)
    # check for complete presence before importing
    module_name = api_to_module[api]

    import imp
    try:
        #importing top level PyQt4/PySide module is ok...
        mod = __import__(module_name)
        #...importing submodules is not
        imp.find_module('QtCore', list(mod.__path__))
        imp.find_module('QtGui', list(mod.__path__))
        imp.find_module('QtSvg', list(mod.__path__))
        if api == QT_API_PYQT5 or api == QT_API_PYSIDE2:
            # QT5 requires QtWidgets too
            imp.find_module('QtWidgets', list(mod.__path__))

        #we can also safely check PySide version
        if api == QT_API_PYSIDE:
            return check_version(mod.__version__, '1.0.3')
        else:
            return True
    except ImportError:
        return False 
Example #19
Source File: Qt.py    From DynRigBuilder with MIT License 5 votes vote down vote up
def _pyside():
    """Initialise PySide"""

    import PySide as module
    extras = ["QtUiTools"]
    try:
        try:
            # Before merge of PySide and shiboken
            import shiboken
        except ImportError:
            # After merge of PySide and shiboken, May 2017
            from PySide import shiboken
        extras.append("shiboken")
    except ImportError:
        pass

    _setup(module, extras)
    Qt.__binding_version__ = module.__version__

    if hasattr(Qt, "_shiboken"):
        Qt.QtCompat.wrapInstance = _wrapinstance
        Qt.QtCompat.getCppPointer = _getcpppointer
        Qt.QtCompat.delete = shiboken.delete

    if hasattr(Qt, "_QtUiTools"):
        Qt.QtCompat.loadUi = _loadUi

    if hasattr(Qt, "_QtGui"):
        setattr(Qt, "QtWidgets", _new_module("QtWidgets"))
        setattr(Qt, "_QtWidgets", Qt._QtGui)
        if hasattr(Qt._QtGui, "QX11Info"):
            setattr(Qt, "QtX11Extras", _new_module("QtX11Extras"))
            Qt.QtX11Extras.QX11Info = Qt._QtGui.QX11Info

        Qt.QtCompat.setSectionResizeMode = Qt._QtGui.QHeaderView.setResizeMode

    if hasattr(Qt, "_QtCore"):
        Qt.__qt_version__ = Qt._QtCore.qVersion()

    _reassign_misplaced_members("PySide")
    _build_compatibility_members("PySide") 
Example #20
Source File: Qt.py    From MouseTracks with GNU General Public License v3.0 5 votes vote down vote up
def _pyside():
    """Initialise PySide"""

    import PySide as module
    extras = ["QtUiTools"]
    try:
        try:
            # Before merge of PySide and shiboken
            import shiboken
        except ImportError:
            # After merge of PySide and shiboken, May 2017
            from PySide import shiboken
        extras.append("shiboken")
    except ImportError:
        pass

    _setup(module, extras)
    Qt.__binding_version__ = module.__version__

    if hasattr(Qt, "_shiboken"):
        Qt.QtCompat.wrapInstance = _wrapinstance
        Qt.QtCompat.getCppPointer = _getcpppointer
        Qt.QtCompat.delete = shiboken.delete

    if hasattr(Qt, "_QtUiTools"):
        Qt.QtCompat.loadUi = _loadUi

    if hasattr(Qt, "_QtGui"):
        setattr(Qt, "QtWidgets", _new_module("QtWidgets"))
        setattr(Qt, "_QtWidgets", Qt._QtGui)
        if hasattr(Qt._QtGui, "QX11Info"):
            setattr(Qt, "QtX11Extras", _new_module("QtX11Extras"))
            Qt.QtX11Extras.QX11Info = Qt._QtGui.QX11Info

        Qt.QtCompat.setSectionResizeMode = Qt._QtGui.QHeaderView.setResizeMode

    if hasattr(Qt, "_QtCore"):
        Qt.__qt_version__ = Qt._QtCore.qVersion()

    _reassign_misplaced_members("PySide")
    _build_compatibility_members("PySide") 
Example #21
Source File: Qt.py    From P4VFX with MIT License 5 votes vote down vote up
def _pyside2():
    """Initialise PySide2

    These functions serve to test the existence of a binding
    along with set it up in such a way that it aligns with
    the final step; adding members from the original binding
    to Qt.py

    """

    import PySide2 as module
    _setup(module, ["QtUiTools"])

    Qt.__binding_version__ = module.__version__

    if hasattr(Qt, "_QtUiTools"):
        Qt.QtCompat.loadUi = lambda fname: \
            Qt._QtUiTools.QUiLoader().load(fname)

    if hasattr(Qt, "_QtGui") and hasattr(Qt, "_QtCore"):
        Qt.QtCore.QStringListModel = Qt._QtGui.QStringListModel

    if hasattr(Qt, "_QtWidgets"):
        Qt.QtCompat.setSectionResizeMode = \
            Qt._QtWidgets.QHeaderView.setSectionResizeMode

    if hasattr(Qt, "_QtCore"):
        Qt.__qt_version__ = Qt._QtCore.qVersion()
        Qt.QtCompat.translate = Qt._QtCore.QCoreApplication.translate

        Qt.QtCore.Property = Qt._QtCore.Property
        Qt.QtCore.Signal = Qt._QtCore.Signal
        Qt.QtCore.Slot = Qt._QtCore.Slot

        Qt.QtCore.QAbstractProxyModel = Qt._QtCore.QAbstractProxyModel
        Qt.QtCore.QSortFilterProxyModel = Qt._QtCore.QSortFilterProxyModel
        Qt.QtCore.QItemSelection = Qt._QtCore.QItemSelection
        Qt.QtCore.QItemSelectionRange = Qt._QtCore.QItemSelectionRange
        Qt.QtCore.QItemSelectionModel = Qt._QtCore.QItemSelectionModel 
Example #22
Source File: conftest.py    From vnpy_crypto with MIT License 4 votes vote down vote up
def pytest_report_header(config):
    """
    This function is used by py.test to insert a customized header into the
    test report.
    """

    versions = os.linesep
    versions += 'PyQt4: '

    try:
        from PyQt4 import Qt
        versions += "PyQt: {0} - Qt: {1}".format(Qt.PYQT_VERSION_STR, Qt.QT_VERSION_STR)
    except ImportError:
        versions += 'not installed'
    except AttributeError:
        versions += 'unknown version'

    versions += os.linesep
    versions += 'PyQt5: '

    try:
        from PyQt5 import Qt
        versions += "PyQt: {0} - Qt: {1}".format(Qt.PYQT_VERSION_STR, Qt.QT_VERSION_STR)
    except ImportError:
        versions += 'not installed'
    except AttributeError:
        versions += 'unknown version'

    versions += os.linesep
    versions += 'PySide: '

    try:
        import PySide
        from PySide import QtCore
        versions += "PySide: {0} - Qt: {1}".format(PySide.__version__, QtCore.__version__)
    except ImportError:
        versions += 'not installed'
    except AttributeError:
        versions += 'unknown version'

    versions += os.linesep
    versions += 'PySide2: '

    try:
        import PySide2
        from PySide2 import QtCore
        versions += "PySide: {0} - Qt: {1}".format(PySide2.__version__, QtCore.__version__)
    except ImportError:
        versions += 'not installed'
    except AttributeError:
        versions += 'unknown version'

    versions += os.linesep
    
    return versions 
Example #23
Source File: Qt.py    From MouseTracks with GNU General Public License v3.0 4 votes vote down vote up
def _pyside2():
    """Initialise PySide2

    These functions serve to test the existence of a binding
    along with set it up in such a way that it aligns with
    the final step; adding members from the original binding
    to Qt.py

    """

    import PySide2 as module
    extras = ["QtUiTools"]
    try:
        try:
            # Before merge of PySide and shiboken
            import shiboken2
        except ImportError:
            # After merge of PySide and shiboken, May 2017
            from PySide2 import shiboken2
        extras.append("shiboken2")
    except ImportError:
        pass

    _setup(module, extras)
    Qt.__binding_version__ = module.__version__

    if hasattr(Qt, "_shiboken2"):
        Qt.QtCompat.wrapInstance = _wrapinstance
        Qt.QtCompat.getCppPointer = _getcpppointer
        Qt.QtCompat.delete = shiboken2.delete

    if hasattr(Qt, "_QtUiTools"):
        Qt.QtCompat.loadUi = _loadUi

    if hasattr(Qt, "_QtCore"):
        Qt.__qt_version__ = Qt._QtCore.qVersion()

    if hasattr(Qt, "_QtWidgets"):
        Qt.QtCompat.setSectionResizeMode = \
            Qt._QtWidgets.QHeaderView.setSectionResizeMode

    _reassign_misplaced_members("PySide2")
    _build_compatibility_members("PySide2") 
Example #24
Source File: Qt.py    From SiShelf with MIT License 4 votes vote down vote up
def _pyside2():
    """Initialise PySide2

    These functions serve to test the existence of a binding
    along with set it up in such a way that it aligns with
    the final step; adding members from the original binding
    to Qt.py

    """

    import PySide2 as module
    extras = ["QtUiTools"]
    try:
        try:
            # Before merge of PySide and shiboken
            import shiboken2
        except ImportError:
            # After merge of PySide and shiboken, May 2017
            from PySide2 import shiboken2
        extras.append("shiboken2")
    except ImportError:
        pass

    _setup(module, extras)
    Qt.__binding_version__ = module.__version__

    if hasattr(Qt, "_shiboken2"):
        Qt.QtCompat.wrapInstance = _wrapinstance
        Qt.QtCompat.getCppPointer = _getcpppointer
        Qt.QtCompat.delete = shiboken2.delete

    if hasattr(Qt, "_QtUiTools"):
        Qt.QtCompat.loadUi = _loadUi

    if hasattr(Qt, "_QtCore"):
        Qt.__qt_version__ = Qt._QtCore.qVersion()
        Qt.QtCompat.dataChanged = (
            lambda self, topleft, bottomright, roles=None:
            self.dataChanged.emit(topleft, bottomright, roles or [])
        )

    if hasattr(Qt, "_QtWidgets"):
        Qt.QtCompat.setSectionResizeMode = \
            Qt._QtWidgets.QHeaderView.setSectionResizeMode

    _reassign_misplaced_members("PySide2")
    _build_compatibility_members("PySide2") 
Example #25
Source File: Qt.py    From SiShelf with MIT License 4 votes vote down vote up
def _pyside():
    """Initialise PySide"""

    import PySide as module
    extras = ["QtUiTools"]
    try:
        try:
            # Before merge of PySide and shiboken
            import shiboken
        except ImportError:
            # After merge of PySide and shiboken, May 2017
            from PySide import shiboken
        extras.append("shiboken")
    except ImportError:
        pass

    _setup(module, extras)
    Qt.__binding_version__ = module.__version__

    if hasattr(Qt, "_shiboken"):
        Qt.QtCompat.wrapInstance = _wrapinstance
        Qt.QtCompat.getCppPointer = _getcpppointer
        Qt.QtCompat.delete = shiboken.delete

    if hasattr(Qt, "_QtUiTools"):
        Qt.QtCompat.loadUi = _loadUi

    if hasattr(Qt, "_QtGui"):
        setattr(Qt, "QtWidgets", _new_module("QtWidgets"))
        setattr(Qt, "_QtWidgets", Qt._QtGui)
        if hasattr(Qt._QtGui, "QX11Info"):
            setattr(Qt, "QtX11Extras", _new_module("QtX11Extras"))
            Qt.QtX11Extras.QX11Info = Qt._QtGui.QX11Info

        Qt.QtCompat.setSectionResizeMode = Qt._QtGui.QHeaderView.setResizeMode

    if hasattr(Qt, "_QtCore"):
        Qt.__qt_version__ = Qt._QtCore.qVersion()
        Qt.QtCompat.dataChanged = (
            lambda self, topleft, bottomright, roles=None:
            self.dataChanged.emit(topleft, bottomright)
        )

    _reassign_misplaced_members("PySide")
    _build_compatibility_members("PySide") 
Example #26
Source File: Qt.py    From Qt.py with MIT License 4 votes vote down vote up
def _pyside2():
    """Initialise PySide2

    These functions serve to test the existence of a binding
    along with set it up in such a way that it aligns with
    the final step; adding members from the original binding
    to Qt.py

    """

    import PySide2 as module
    extras = ["QtUiTools"]
    try:
        try:
            # Before merge of PySide and shiboken
            import shiboken2
        except ImportError:
            # After merge of PySide and shiboken, May 2017
            from PySide2 import shiboken2
        extras.append("shiboken2")
    except ImportError:
        pass

    _setup(module, extras)
    Qt.__binding_version__ = module.__version__

    if hasattr(Qt, "_shiboken2"):
        Qt.QtCompat.wrapInstance = _wrapinstance
        Qt.QtCompat.getCppPointer = _getcpppointer
        Qt.QtCompat.delete = shiboken2.delete

    if hasattr(Qt, "_QtUiTools"):
        Qt.QtCompat.loadUi = _loadUi

    if hasattr(Qt, "_QtCore"):
        Qt.__qt_version__ = Qt._QtCore.qVersion()
        Qt.QtCompat.dataChanged = (
            lambda self, topleft, bottomright, roles=None:
            self.dataChanged.emit(topleft, bottomright, roles or [])
        )

    if hasattr(Qt, "_QtWidgets"):
        Qt.QtCompat.setSectionResizeMode = \
            Qt._QtWidgets.QHeaderView.setSectionResizeMode

    _reassign_misplaced_members("PySide2")
    _build_compatibility_members("PySide2") 
Example #27
Source File: Qt.py    From Qt.py with MIT License 4 votes vote down vote up
def _pyside():
    """Initialise PySide"""

    import PySide as module
    extras = ["QtUiTools"]
    try:
        try:
            # Before merge of PySide and shiboken
            import shiboken
        except ImportError:
            # After merge of PySide and shiboken, May 2017
            from PySide import shiboken
        extras.append("shiboken")
    except ImportError:
        pass

    _setup(module, extras)
    Qt.__binding_version__ = module.__version__

    if hasattr(Qt, "_shiboken"):
        Qt.QtCompat.wrapInstance = _wrapinstance
        Qt.QtCompat.getCppPointer = _getcpppointer
        Qt.QtCompat.delete = shiboken.delete

    if hasattr(Qt, "_QtUiTools"):
        Qt.QtCompat.loadUi = _loadUi

    if hasattr(Qt, "_QtGui"):
        setattr(Qt, "QtWidgets", _new_module("QtWidgets"))
        setattr(Qt, "_QtWidgets", Qt._QtGui)
        if hasattr(Qt._QtGui, "QX11Info"):
            setattr(Qt, "QtX11Extras", _new_module("QtX11Extras"))
            Qt.QtX11Extras.QX11Info = Qt._QtGui.QX11Info

        Qt.QtCompat.setSectionResizeMode = Qt._QtGui.QHeaderView.setResizeMode

    if hasattr(Qt, "_QtCore"):
        Qt.__qt_version__ = Qt._QtCore.qVersion()
        Qt.QtCompat.dataChanged = (
            lambda self, topleft, bottomright, roles=None:
            self.dataChanged.emit(topleft, bottomright)
        )

    _reassign_misplaced_members("PySide")
    _build_compatibility_members("PySide") 
Example #28
Source File: conftest.py    From qtpy with MIT License 4 votes vote down vote up
def pytest_report_header(config):
    """
    This function is used by py.test to insert a customized header into the
    test report.
    """

    versions = os.linesep
    versions += 'PyQt4: '

    try:
        from PyQt4 import Qt
        versions += "PyQt: {0} - Qt: {1}".format(Qt.PYQT_VERSION_STR, Qt.QT_VERSION_STR)
    except ImportError:
        versions += 'not installed'
    except AttributeError:
        versions += 'unknown version'

    versions += os.linesep
    versions += 'PyQt5: '

    try:
        from PyQt5 import Qt
        versions += "PyQt: {0} - Qt: {1}".format(Qt.PYQT_VERSION_STR, Qt.QT_VERSION_STR)
    except ImportError:
        versions += 'not installed'
    except AttributeError:
        versions += 'unknown version'

    versions += os.linesep
    versions += 'PySide: '

    try:
        import PySide
        from PySide import QtCore
        versions += "PySide: {0} - Qt: {1}".format(PySide.__version__, QtCore.__version__)
    except ImportError:
        versions += 'not installed'
    except AttributeError:
        versions += 'unknown version'

    versions += os.linesep
    versions += 'PySide2: '

    try:
        import PySide2
        from PySide2 import QtCore
        versions += "PySide: {0} - Qt: {1}".format(PySide2.__version__, QtCore.__version__)
    except ImportError:
        versions += 'not installed'
    except AttributeError:
        versions += 'unknown version'

    versions += os.linesep
    
    return versions 
Example #29
Source File: frontend_widget.py    From Computable with MIT License 4 votes vote down vote up
def __init__(self, *args, **kw):
        super(FrontendWidget, self).__init__(*args, **kw)
        # FIXME: remove this when PySide min version is updated past 1.0.7
        # forcefully disable calltips if PySide is < 1.0.7, because they crash
        if qt.QT_API == qt.QT_API_PYSIDE:
            import PySide
            if PySide.__version_info__ < (1,0,7):
                self.log.warn("PySide %s < 1.0.7 detected, disabling calltips" % PySide.__version__)
                self.enable_calltips = False

        # FrontendWidget protected variables.
        self._bracket_matcher = BracketMatcher(self._control)
        self._call_tip_widget = CallTipWidget(self._control)
        self._completion_lexer = CompletionLexer(PythonLexer())
        self._copy_raw_action = QtGui.QAction('Copy (Raw Text)', None)
        self._hidden = False
        self._highlighter = FrontendHighlighter(self)
        self._input_splitter = self._input_splitter_class()
        self._kernel_manager = None
        self._kernel_client = None
        self._request_info = {}
        self._request_info['execute'] = {};
        self._callback_dict = {}

        # Configure the ConsoleWidget.
        self.tab_width = 4
        self._set_continuation_prompt('... ')

        # Configure the CallTipWidget.
        self._call_tip_widget.setFont(self.font)
        self.font_changed.connect(self._call_tip_widget.setFont)

        # Configure actions.
        action = self._copy_raw_action
        key = QtCore.Qt.CTRL | QtCore.Qt.SHIFT | QtCore.Qt.Key_C
        action.setEnabled(False)
        action.setShortcut(QtGui.QKeySequence(key))
        action.setShortcutContext(QtCore.Qt.WidgetWithChildrenShortcut)
        action.triggered.connect(self.copy_raw)
        self.copy_available.connect(action.setEnabled)
        self.addAction(action)

        # Connect signal handlers.
        document = self._control.document()
        document.contentsChange.connect(self._document_contents_change)

        # Set flag for whether we are connected via localhost.
        self._local_kernel = kw.get('local_kernel',
                                    FrontendWidget._local_kernel)

    #---------------------------------------------------------------------------
    # 'ConsoleWidget' public interface
    #--------------------------------------------------------------------------- 
Example #30
Source File: Qt.py    From pyblish-qml with GNU Lesser General Public License v3.0 4 votes vote down vote up
def _pyside2():
    """Initialise PySide2

    These functions serve to test the existence of a binding
    along with set it up in such a way that it aligns with
    the final step; adding members from the original binding
    to Qt.py

    """

    import PySide2 as module
    extras = ["QtUiTools"]
    try:
        try:
            # Before merge of PySide and shiboken
            import shiboken2
        except ImportError:
            # After merge of PySide and shiboken, May 2017
            from PySide2 import shiboken2
        extras.append("shiboken2")
    except ImportError:
        pass

    _setup(module, extras)
    Qt.__binding_version__ = module.__version__

    if hasattr(Qt, "_shiboken2"):
        Qt.QtCompat.wrapInstance = _wrapinstance
        Qt.QtCompat.getCppPointer = _getcpppointer
        Qt.QtCompat.delete = shiboken2.delete

    if hasattr(Qt, "_QtUiTools"):
        Qt.QtCompat.loadUi = _loadUi

    if hasattr(Qt, "_QtCore"):
        Qt.__qt_version__ = Qt._QtCore.qVersion()
        Qt.QtCompat.dataChanged = (
            lambda self, topleft, bottomright, roles=None:
            self.dataChanged.emit(topleft, bottomright, roles or [])
        )

    if hasattr(Qt, "_QtWidgets"):
        Qt.QtCompat.setSectionResizeMode = \
            Qt._QtWidgets.QHeaderView.setSectionResizeMode

    _reassign_misplaced_members("PySide2")
    _build_compatibility_members("PySide2")