Python sip.setapi() Examples
The following are 28
code examples of sip.setapi().
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
sip
, or try the search function
.
Example #1
Source File: __init__.py From pyqode.qt with MIT License | 6 votes |
def setup_apiv2(): """ Setup apiv2 when using PyQt4 and Python2. """ # setup PyQt api to version 2 if sys.version_info[0] == 2: logging.getLogger(__name__).debug( 'setting up SIP API to version 2') import sip try: sip.setapi("QString", 2) sip.setapi("QVariant", 2) except ValueError: logging.getLogger(__name__).critical( "failed to set up sip api to version 2 for PyQt4") raise ImportError('PyQt4')
Example #2
Source File: __init__.py From PFramer with GNU General Public License v3.0 | 6 votes |
def setup_apiv2(): """ Setup apiv2 when using PyQt4 and Python2. """ # setup PyQt api to version 2 if sys.version_info[0] == 2: logging.getLogger(__name__).debug( 'setting up SIP API to version 2') import sip try: sip.setapi("QString", 2) sip.setapi("QVariant", 2) except ValueError: logging.getLogger(__name__).critical( "failed to set up sip api to version 2 for PyQt4") raise ImportError('PyQt4')
Example #3
Source File: __init__.py From Turing with MIT License | 6 votes |
def setup_apiv2(): """ Setup apiv2 when using PyQt4 and Python2. """ # setup PyQt api to version 2 if sys.version_info[0] == 2: logging.getLogger(__name__).debug( 'setting up SIP API to version 2') import sip try: sip.setapi("QString", 2) sip.setapi("QVariant", 2) except ValueError: logging.getLogger(__name__).critical( "failed to set up sip api to version 2 for PyQt4") raise ImportError('PyQt4')
Example #4
Source File: qt_loaders.py From Carnets with BSD 3-Clause "New" or "Revised" License | 5 votes |
def import_pyqt4(version=2): """ Import PyQt4 Parameters ---------- version : 1, 2, or None Which QString/QVariant API to use. Set to None to use the system default ImportErrors rasied within this function are non-recoverable """ # The new-style string API (version=2) automatically # converts QStrings to Unicode Python strings. Also, automatically unpacks # QVariants to their underlying objects. import sip if version is not None: sip.setapi('QString', version) sip.setapi('QVariant', version) from PyQt4 import QtGui, QtCore, QtSvg if not check_version(QtCore.PYQT_VERSION_STR, '4.7'): raise ImportError("QtConsole requires PyQt4 >= 4.7, found %s" % QtCore.PYQT_VERSION_STR) # Alias PyQt-specific functions for PySide compatibility. QtCore.Signal = QtCore.pyqtSignal QtCore.Slot = QtCore.pyqtSlot # query for the API version (in case version == None) version = sip.getapi('QString') api = QT_API_PYQTv1 if version == 1 else QT_API_PYQT return QtCore, QtGui, QtSvg, api
Example #5
Source File: qt_loaders.py From Computable with MIT License | 5 votes |
def import_pyqt4(version=2): """ Import PyQt4 Parameters ---------- version : 1, 2, or None Which QString/QVariant API to use. Set to None to use the system default ImportErrors rasied within this function are non-recoverable """ # The new-style string API (version=2) automatically # converts QStrings to Unicode Python strings. Also, automatically unpacks # QVariants to their underlying objects. import sip if version is not None: sip.setapi('QString', version) sip.setapi('QVariant', version) from PyQt4 import QtGui, QtCore, QtSvg if not check_version(QtCore.PYQT_VERSION_STR, '4.7'): raise ImportError("IPython requires PyQt4 >= 4.7, found %s" % QtCore.PYQT_VERSION_STR) # Alias PyQt-specific functions for PySide compatibility. QtCore.Signal = QtCore.pyqtSignal QtCore.Slot = QtCore.pyqtSlot # query for the API version (in case version == None) version = sip.getapi('QString') api = QT_API_PYQTv1 if version == 1 else QT_API_PYQT return QtCore, QtGui, QtSvg, api
Example #6
Source File: qt_loaders.py From filmkodi with Apache License 2.0 | 5 votes |
def import_pyqt4(version=2): """ Import PyQt4 Parameters ---------- version : 1, 2, or None Which QString/QVariant API to use. Set to None to use the system default ImportErrors rasied within this function are non-recoverable """ # The new-style string API (version=2) automatically # converts QStrings to Unicode Python strings. Also, automatically unpacks # QVariants to their underlying objects. import sip if version is not None: sip.setapi('QString', version) sip.setapi('QVariant', version) from PyQt4 import QtGui, QtCore, QtSvg if not check_version(QtCore.PYQT_VERSION_STR, '4.7'): raise ImportError("IPython requires PyQt4 >= 4.7, found %s" % QtCore.PYQT_VERSION_STR) # Alias PyQt-specific functions for PySide compatibility. QtCore.Signal = QtCore.pyqtSignal QtCore.Slot = QtCore.pyqtSlot # query for the API version (in case version == None) version = sip.getapi('QString') api = QT_API_PYQTv1 if version == 1 else QT_API_PYQT return QtCore, QtGui, QtSvg, api
Example #7
Source File: qt_loaders.py From PyDev.Debugger with Eclipse Public License 1.0 | 5 votes |
def import_pyqt4(version=2): """ Import PyQt4 Parameters ---------- version : 1, 2, or None Which QString/QVariant API to use. Set to None to use the system default ImportErrors raised within this function are non-recoverable """ # The new-style string API (version=2) automatically # converts QStrings to Unicode Python strings. Also, automatically unpacks # QVariants to their underlying objects. import sip if version is not None: sip.setapi('QString', version) sip.setapi('QVariant', version) from PyQt4 import QtGui, QtCore, QtSvg if not check_version(QtCore.PYQT_VERSION_STR, '4.7'): raise ImportError("IPython requires PyQt4 >= 4.7, found %s" % QtCore.PYQT_VERSION_STR) # Alias PyQt-specific functions for PySide compatibility. QtCore.Signal = QtCore.pyqtSignal QtCore.Slot = QtCore.pyqtSlot # query for the API version (in case version == None) version = sip.getapi('QString') api = QT_API_PYQTv1 if version == 1 else QT_API_PYQT return QtCore, QtGui, QtSvg, api
Example #8
Source File: tests.py From Qt.py with MIT License | 5 votes |
def test_sip_api_2_2(): """sip=2, hint=2 == OK""" import sip sip.setapi("QString", 2) os.environ["QT_SIP_API_HINT"] = "2" __import__("Qt") # Bypass linter warning
Example #9
Source File: installers.py From ibeis with Apache License 2.0 | 5 votes |
def fix_pyinstaller_sip_api(): """ Hack to get the correct version of SIP for win32 References: http://stackoverflow.com/questions/21217399/pyqt4-qtcore-qvariant-object-instead-of-a-string """ import PyInstaller from os.path import dirname, join # NOQA hook_fpath = join(dirname(PyInstaller.__file__), 'loader', 'rthooks', 'pyi_rth_qt4plugins.py') patch_code = ut.codeblock( ''' try: import sip # http://stackoverflow.com/questions/21217399/pyqt4-qtcore-qvariant-object-instead-of-a-string sip.setapi('QVariant', 2) sip.setapi('QString', 2) sip.setapi('QTextStream', 2) sip.setapi('QTime', 2) sip.setapi('QUrl', 2) sip.setapi('QDate', 2) sip.setapi('QDateTime', 2) if hasattr(sip, 'setdestroyonexit'): sip.setdestroyonexit(False) # This prevents a crash on windows except ValueError as ex: print('Warning: Value Error: %s' % str(ex)) pass ''') fpath = hook_fpath # Patch the hook file tag = 'SIP_API_2' ut.inject_python_code(fpath, patch_code, tag) #ut.editfile(hook_fpath) pass
Example #10
Source File: __init__.py From QMusic with GNU Lesser General Public License v2.1 | 5 votes |
def setup_apiv2(): """ Setup apiv2 when using PyQt4 and Python2. """ # setup PyQt api to version 2 if sys.version_info[0] == 2: logging.getLogger(__name__).debug('setting up SIP API to version 2') import sip try: sip.setapi("QString", 2) sip.setapi("QVariant", 2) except ValueError: logging.getLogger(__name__).critical( "failed to set up sip api to version 2 for PyQt4") raise ImportError('PyQt4')
Example #11
Source File: tests.py From Qt.py with MIT License | 5 votes |
def test_sip_api_1_2(): """sip=1, hint=2 == WARNING""" import sip sip.setapi("QString", 1) os.environ["QT_SIP_API_HINT"] = "2" with captured_output() as out: __import__("Qt") # Bypass linter warning stdout, stderr = out assert stderr.getvalue().startswith("Warning:")
Example #12
Source File: tests.py From Qt.py with MIT License | 5 votes |
def test_sip_api_2_1(): """sip=2, hint=1 == WARNING""" import sip sip.setapi("QString", 2) os.environ["QT_SIP_API_HINT"] = "1" with captured_output() as out: __import__("Qt") # Bypass linter warning stdout, stderr = out assert stderr.getvalue().startswith("Warning:")
Example #13
Source File: qt_loaders.py From pySINDy with MIT License | 5 votes |
def import_pyqt4(version=2): """ Import PyQt4 Parameters ---------- version : 1, 2, or None Which QString/QVariant API to use. Set to None to use the system default ImportErrors rasied within this function are non-recoverable """ # The new-style string API (version=2) automatically # converts QStrings to Unicode Python strings. Also, automatically unpacks # QVariants to their underlying objects. import sip if version is not None: sip.setapi('QString', version) sip.setapi('QVariant', version) from PyQt4 import QtGui, QtCore, QtSvg if not check_version(QtCore.PYQT_VERSION_STR, '4.7'): raise ImportError("QtConsole requires PyQt4 >= 4.7, found %s" % QtCore.PYQT_VERSION_STR) # Alias PyQt-specific functions for PySide compatibility. QtCore.Signal = QtCore.pyqtSignal QtCore.Slot = QtCore.pyqtSlot # query for the API version (in case version == None) version = sip.getapi('QString') api = QT_API_PYQTv1 if version == 1 else QT_API_PYQT return QtCore, QtGui, QtSvg, api
Example #14
Source File: tests.py From Qt.py with MIT License | 5 votes |
def test_sip_api_1_1(): """sip=1, hint=1 == OK""" import sip sip.setapi("QString", 1) os.environ["QT_SIP_API_HINT"] = "1" __import__("Qt") # Bypass linter warning
Example #15
Source File: tests.py From Qt.py with MIT License | 5 votes |
def test_sip_api_already_set(): """Raise ImportError with sip was set to 1 with no hint, default""" __import__("PyQt4.QtCore") # Bypass linter warning import sip sip.setapi("QString", 1) assert_raises(ImportError, __import__, "Qt") # A sip API hint of any kind bypasses ImportError # on account of it being merely a hint.
Example #16
Source File: binding_helper.py From compoundpi with GNU General Public License v2.0 | 4 votes |
def _load_pyqt(required_modules, optional_modules): os.environ['QT_API'] = 'pyqt' # select PyQt4 API, see # http://pyqt.sourceforge.net/Docs/PyQt4/incompatible_apis.html import sip try: sip.setapi('QDate', 2) sip.setapi('QDateTime', 2) sip.setapi('QString', 2) sip.setapi('QTextStream', 2) sip.setapi('QTime', 2) sip.setapi('QUrl', 2) sip.setapi('QVariant', 2) except ValueError as e: raise RuntimeError( 'Could not set API version (%s): did you import PyQt4 ' 'directly?' % e) for module_name in required_modules: _named_import('PyQt4.%s' % module_name) for module_name in optional_modules: _named_optional_import('PyQt4.%s' % module_name) # set some names for compatibility with PySide sys.modules['PyQt4.QtCore'].Signal = sys.modules['PyQt4.QtCore'].pyqtSignal sys.modules['PyQt4.QtCore'].Slot = sys.modules['PyQt4.QtCore'].pyqtSlot sys.modules['PyQt4.QtCore'].Property = sys.modules['PyQt4.QtCore'].pyqtProperty try: import PyQt4.Qwt5 _register_binding_module('Qwt', PyQt4.Qwt5) except ImportError: pass global _loadUi def _loadUi(uifile, baseinstance=None, custom_widgets_=None): from PyQt4 import uic return uic.loadUi(uifile, baseinstance=baseinstance) # override specific function to improve compatibility between different # bindings from PyQt4.QtGui import QFileDialog QFileDialog.getOpenFileName = QFileDialog.getOpenFileNameAndFilter QFileDialog.getSaveFileName = QFileDialog.getSaveFileNameAndFilter import PyQt4.QtCore return PyQt4.QtCore.PYQT_VERSION_STR
Example #17
Source File: __init__.py From sixcells with GNU General Public License v3.0 | 4 votes |
def load_module(fullname): if fullname in _sys.modules: return _sys.modules[fullname] _, name = fullname.split('.') global qt if qt: # If a Qt implementation was already selected previously # and the selected module is the same as the one being imported, # then return it, otherwise False. if qt.__name__ == name: _sys.modules[fullname] = qt; return qt else: _sys.modules[fullname] = False; return False if name == 'PyQt4' and _sys.version_info[0] == 2: # Select API version 2, this is needed only for PyQt4 on Python 2.x try: import sip for api in ['QDate', 'QDateTime', 'QString', 'QTextStream', 'QTime', 'QUrl', 'QVariant']: try: sip.setapi(api, 2) except Exception: pass except Exception: pass # The selection of Qt implementation is successful only if its QtCore # module can be imported. try: qt = __import__(name + '.QtCore') except ImportError: _sys.modules[fullname] = False; return False core = qt.QtCore # Turn `QtCore.Qt` object into a package, # because `import qt` will actually give this object. core.Qt.__path__ = [] core.Qt.__package__ = 'qt' # Put some additional attributes into `qt`. core.Qt.module = name core.Qt.version_str = core.qVersion() core.Qt.major = int(core.Qt.version_str.split('.', 1)[0]) if name.startswith('PyQt'): core.Qt.module_version_str = core.PYQT_VERSION_STR core.Signal = core.pyqtSignal core.Slot = core.pyqtSlot else: core.Qt.module_version_str = qt.__version__ core.Qt.Signal = core.Signal core.Qt.Slot = core.Slot _sys.modules[fullname] = qt; return qt
Example #18
Source File: binding_helper.py From calfem-python with MIT License | 4 votes |
def _load_pyqt(required_modules, optional_modules): # set environment variable QT_API for matplotlib os.environ['QT_API'] = 'pyqt' # select PyQt4 API, see http://pyqt.sourceforge.net/Docs/PyQt4/incompatible_apis.html import sip try: sip.setapi('QDate', 2) sip.setapi('QDateTime', 2) sip.setapi('QString', 2) sip.setapi('QTextStream', 2) sip.setapi('QTime', 2) sip.setapi('QUrl', 2) sip.setapi('QVariant', 2) except ValueError as e: raise RuntimeError('Could not set API version (%s): did you import PyQt4 directly?' % e) # register required and optional PyQt4 modules for module_name in required_modules: _named_import('PyQt4.%s' % module_name) for module_name in optional_modules: _named_optional_import('PyQt4.%s' % module_name) # set some names for compatibility with PySide sys.modules['QtCore'].Signal = sys.modules['QtCore'].pyqtSignal sys.modules['QtCore'].Slot = sys.modules['QtCore'].pyqtSlot sys.modules['QtCore'].Property = sys.modules['QtCore'].pyqtProperty # try to register PyQt4.Qwt5 module try: import PyQt4.Qwt5 _register_binding_module('Qwt', PyQt4.Qwt5) except ImportError: pass global _loadUi def _loadUi(uifile, baseinstance=None, custom_widgets_=None): from PyQt4 import uic return uic.loadUi(uifile, baseinstance=baseinstance) # override specific function to improve compatibility between different bindings from QtGui import QFileDialog QFileDialog.getOpenFileName = QFileDialog.getOpenFileNameAndFilter QFileDialog.getSaveFileName = QFileDialog.getSaveFileNameAndFilter import PyQt4.QtCore return PyQt4.QtCore.PYQT_VERSION_STR
Example #19
Source File: Qt.py From pyblish-maya with GNU Lesser General Public License v3.0 | 3 votes |
def _pyqt4(): # Attempt to set sip API v2 (must be done prior to importing PyQt4) import sip try: 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 AttributeError: raise ImportError # PyQt4 < v4.6 except ValueError: # API version already set to v1 raise ImportError import PyQt4.Qt from PyQt4 import QtCore, QtGui, uic _remap(PyQt4, "QtWidgets", QtGui) _remap(QtCore, "Signal", QtCore.pyqtSignal) _remap(QtCore, "Slot", QtCore.pyqtSlot) _remap(QtCore, "Property", QtCore.pyqtProperty) _remap(QtCore, "QItemSelection", QtGui.QItemSelection) _remap(QtCore, "QStringListModel", QtGui.QStringListModel) _remap(QtCore, "QItemSelectionModel", QtGui.QItemSelectionModel) _remap(QtCore, "QSortFilterProxyModel", QtGui.QSortFilterProxyModel) _remap(QtCore, "QAbstractProxyModel", QtGui.QAbstractProxyModel) try: from PyQt4 import QtWebKit _remap(PyQt4, "QtWebKitWidgets", QtWebKit) except ImportError: "QtWebkit is optional in Qt , therefore might not be available" _add(QtCompat, "__binding__", PyQt4.__name__) _add(QtCompat, "__binding_version__", PyQt4.QtCore.PYQT_VERSION_STR) _add(QtCompat, "__qt_version__", PyQt4.QtCore.QT_VERSION_STR) _add(QtCompat, "load_ui", lambda fname: uic.loadUi(fname)) _add(QtCompat, "setSectionResizeMode", QtGui.QHeaderView.setResizeMode) # PySide2 differs from Qt4 in that Qt4 has one extra argument # which is always `None`. The lambda arguments represents the PySide2 # interface, whereas the arguments passed to `.translate` represent # those expected of a Qt4 binding. _add(QtCompat, "translate", lambda context, sourceText, disambiguation, n: QtCore.QCoreApplication.translate(context, sourceText, disambiguation, QtCore.QCoreApplication.CodecForTr, n)) _maintain_backwards_compatibility(PyQt4) return PyQt4
Example #20
Source File: Qt.py From CNCGToolKit with MIT License | 3 votes |
def _pyqt4(): # Attempt to set sip API v2 (must be done prior to importing PyQt4) import sip try: 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 AttributeError: raise ImportError # PyQt4 < v4.6 except ValueError: # API version already set to v1 raise ImportError import PyQt4.Qt from PyQt4 import QtCore, QtGui, uic _remap(PyQt4, "QtWidgets", QtGui) _remap(QtCore, "Signal", QtCore.pyqtSignal) _remap(QtCore, "Slot", QtCore.pyqtSlot) _remap(QtCore, "Property", QtCore.pyqtProperty) _remap(QtCore, "QItemSelection", QtGui.QItemSelection) _remap(QtCore, "QStringListModel", QtGui.QStringListModel) _remap(QtCore, "QItemSelectionModel", QtGui.QItemSelectionModel) _remap(QtCore, "QSortFilterProxyModel", QtGui.QSortFilterProxyModel) _remap(QtCore, "QAbstractProxyModel", QtGui.QAbstractProxyModel) try: from PyQt4 import QtWebKit _remap(PyQt4, "QtWebKitWidgets", QtWebKit) except ImportError: # QtWebkit is optional in Qt , therefore might not be available pass _add(PyQt4, "QtCompat", self) _add(PyQt4, "__binding__", PyQt4.__name__) _add(PyQt4, "load_ui", lambda fname: uic.loadUi(fname)) _add(PyQt4, "translate", lambda context, sourceText, disambiguation, n: ( QtCore.QCoreApplication(context, sourceText, disambiguation, None, n))) _add(PyQt4, "setSectionResizeMode", QtGui.QHeaderView.setResizeMode) _maintain_backwards_compatibility(PyQt4) return PyQt4
Example #21
Source File: Qt.py From uExport with zlib License | 3 votes |
def _pyqt4(): # Attempt to set sip API v2 (must be done prior to importing PyQt4) import sip try: 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 AttributeError: raise ImportError # PyQt4 < v4.6 except ValueError: # API version already set to v1 raise ImportError import PyQt4.Qt from PyQt4 import QtCore, QtGui, uic _remap(PyQt4, "QtWidgets", QtGui) _remap(QtCore, "Signal", QtCore.pyqtSignal) _remap(QtCore, "Slot", QtCore.pyqtSlot) _remap(QtCore, "Property", QtCore.pyqtProperty) _remap(QtCore, "QItemSelection", QtGui.QItemSelection) _remap(QtCore, "QStringListModel", QtGui.QStringListModel) _remap(QtCore, "QItemSelectionModel", QtGui.QItemSelectionModel) _remap(QtCore, "QSortFilterProxyModel", QtGui.QSortFilterProxyModel) _remap(QtCore, "QAbstractProxyModel", QtGui.QAbstractProxyModel) try: from PyQt4 import QtWebKit _remap(PyQt4, "QtWebKitWidgets", QtWebKit) except ImportError: # QtWebkit is optional in Qt , therefore might not be available pass _add(PyQt4, "QtCompat", self) _add(PyQt4, "__binding__", PyQt4.__name__) _add(PyQt4, "load_ui", lambda fname: uic.loadUi(fname)) _add(PyQt4, "translate", lambda context, sourceText, disambiguation, n: ( QtCore.QCoreApplication(context, sourceText, disambiguation, None, n))) _add(PyQt4, "setSectionResizeMode", QtGui.QHeaderView.setResizeMode) _maintain_backwards_compatibility(PyQt4) return PyQt4
Example #22
Source File: Qt.py From pipeline with MIT License | 3 votes |
def _pyqt4(): # Attempt to set sip API v2 (must be done prior to importing PyQt4) import sip try: 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 AttributeError: raise ImportError # PyQt4 < v4.6 except ValueError: # API version already set to v1 raise ImportError import PyQt4.Qt from PyQt4 import QtCore, QtGui, uic _remap(PyQt4, "QtWidgets", QtGui) _remap(QtCore, "Signal", QtCore.pyqtSignal) _remap(QtCore, "Slot", QtCore.pyqtSlot) _remap(QtCore, "Property", QtCore.pyqtProperty) _remap(QtCore, "QItemSelection", QtGui.QItemSelection) _remap(QtCore, "QStringListModel", QtGui.QStringListModel) _remap(QtCore, "QItemSelectionModel", QtGui.QItemSelectionModel) _remap(QtCore, "QSortFilterProxyModel", QtGui.QSortFilterProxyModel) _remap(QtCore, "QAbstractProxyModel", QtGui.QAbstractProxyModel) try: from PyQt4 import QtWebKit _remap(PyQt4, "QtWebKitWidgets", QtWebKit) except ImportError: # QtWebkit is optional in Qt , therefore might not be available pass _add(PyQt4, "QtCompat", self) _add(PyQt4, "__binding__", PyQt4.__name__) _add(PyQt4, "load_ui", lambda fname: uic.loadUi(fname)) _add(PyQt4, "translate", lambda context, sourceText, disambiguation, n: ( QtCore.QCoreApplication(context, sourceText, disambiguation, None, n))) _add(PyQt4, "setSectionResizeMode", QtGui.QHeaderView.setResizeMode) _maintain_backwards_compatibility(PyQt4) return PyQt4
Example #23
Source File: qt_compat.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 2 votes |
def _setup_pyqt4(): global QtCore, QtGui, QtWidgets, __version__, is_pyqt5, _getSaveFileName def _setup_pyqt4_internal(api): global QtCore, QtGui, QtWidgets, \ __version__, is_pyqt5, _getSaveFileName # List of incompatible APIs: # http://pyqt.sourceforge.net/Docs/PyQt4/incompatible_apis.html _sip_apis = ["QDate", "QDateTime", "QString", "QTextStream", "QTime", "QUrl", "QVariant"] try: import sip except ImportError: pass else: for _sip_api in _sip_apis: try: sip.setapi(_sip_api, api) except ValueError: pass from PyQt4 import QtCore, QtGui __version__ = QtCore.PYQT_VERSION_STR # PyQt 4.6 introduced getSaveFileNameAndFilter: # https://riverbankcomputing.com/news/pyqt-46 if __version__ < LooseVersion("4.6"): raise ImportError("PyQt<4.6 is not supported") QtCore.Signal = QtCore.pyqtSignal QtCore.Slot = QtCore.pyqtSlot QtCore.Property = QtCore.pyqtProperty _getSaveFileName = QtGui.QFileDialog.getSaveFileNameAndFilter if QT_API == QT_API_PYQTv2: _setup_pyqt4_internal(api=2) elif QT_API == QT_API_PYSIDE: from PySide import QtCore, QtGui, __version__, __version_info__ # PySide 1.0.3 fixed the following: # https://srinikom.github.io/pyside-bz-archive/809.html if __version_info__ < (1, 0, 3): raise ImportError("PySide<1.0.3 is not supported") _getSaveFileName = QtGui.QFileDialog.getSaveFileName elif QT_API == QT_API_PYQT: _setup_pyqt4_internal(api=1) else: raise ValueError("Unexpected value for the 'backend.qt4' rcparam") QtWidgets = QtGui def is_pyqt5(): return False
Example #24
Source File: qt_compat.py From GraphicDesignPatternByPython with MIT License | 2 votes |
def _setup_pyqt4(): global QtCore, QtGui, QtWidgets, __version__, is_pyqt5, _getSaveFileName def _setup_pyqt4_internal(api): global QtCore, QtGui, QtWidgets, \ __version__, is_pyqt5, _getSaveFileName # List of incompatible APIs: # http://pyqt.sourceforge.net/Docs/PyQt4/incompatible_apis.html _sip_apis = ["QDate", "QDateTime", "QString", "QTextStream", "QTime", "QUrl", "QVariant"] try: import sip except ImportError: pass else: for _sip_api in _sip_apis: try: sip.setapi(_sip_api, api) except ValueError: pass from PyQt4 import QtCore, QtGui __version__ = QtCore.PYQT_VERSION_STR # PyQt 4.6 introduced getSaveFileNameAndFilter: # https://riverbankcomputing.com/news/pyqt-46 if __version__ < LooseVersion("4.6"): raise ImportError("PyQt<4.6 is not supported") QtCore.Signal = QtCore.pyqtSignal QtCore.Slot = QtCore.pyqtSlot QtCore.Property = QtCore.pyqtProperty _getSaveFileName = QtGui.QFileDialog.getSaveFileNameAndFilter if QT_API == QT_API_PYQTv2: _setup_pyqt4_internal(api=2) elif QT_API == QT_API_PYSIDE: from PySide import QtCore, QtGui, __version__, __version_info__ # PySide 1.0.3 fixed the following: # https://srinikom.github.io/pyside-bz-archive/809.html if __version_info__ < (1, 0, 3): raise ImportError("PySide<1.0.3 is not supported") _getSaveFileName = QtGui.QFileDialog.getSaveFileName elif QT_API == QT_API_PYQT: _setup_pyqt4_internal(api=1) else: raise ValueError("Unexpected value for the 'backend.qt4' rcparam") QtWidgets = QtGui def is_pyqt5(): return False
Example #25
Source File: qt_compat.py From Mastering-Elasticsearch-7.0 with MIT License | 2 votes |
def _setup_pyqt4(): global QtCore, QtGui, QtWidgets, __version__, is_pyqt5, _getSaveFileName def _setup_pyqt4_internal(api): global QtCore, QtGui, QtWidgets, \ __version__, is_pyqt5, _getSaveFileName # List of incompatible APIs: # http://pyqt.sourceforge.net/Docs/PyQt4/incompatible_apis.html _sip_apis = ["QDate", "QDateTime", "QString", "QTextStream", "QTime", "QUrl", "QVariant"] try: import sip except ImportError: pass else: for _sip_api in _sip_apis: try: sip.setapi(_sip_api, api) except ValueError: pass from PyQt4 import QtCore, QtGui __version__ = QtCore.PYQT_VERSION_STR # PyQt 4.6 introduced getSaveFileNameAndFilter: # https://riverbankcomputing.com/news/pyqt-46 if __version__ < LooseVersion("4.6"): raise ImportError("PyQt<4.6 is not supported") QtCore.Signal = QtCore.pyqtSignal QtCore.Slot = QtCore.pyqtSlot QtCore.Property = QtCore.pyqtProperty _getSaveFileName = QtGui.QFileDialog.getSaveFileNameAndFilter if QT_API == QT_API_PYQTv2: _setup_pyqt4_internal(api=2) elif QT_API == QT_API_PYSIDE: from PySide import QtCore, QtGui, __version__, __version_info__ # PySide 1.0.3 fixed the following: # https://srinikom.github.io/pyside-bz-archive/809.html if __version_info__ < (1, 0, 3): raise ImportError("PySide<1.0.3 is not supported") _getSaveFileName = QtGui.QFileDialog.getSaveFileName elif QT_API == QT_API_PYQT: _setup_pyqt4_internal(api=1) else: raise ValueError("Unexpected value for the 'backend.qt4' rcparam") QtWidgets = QtGui def is_pyqt5(): return False
Example #26
Source File: qt_compat.py From coffeegrindsize with MIT License | 2 votes |
def _setup_pyqt4(): global QtCore, QtGui, QtWidgets, __version__, is_pyqt5, _getSaveFileName def _setup_pyqt4_internal(api): global QtCore, QtGui, QtWidgets, \ __version__, is_pyqt5, _getSaveFileName # List of incompatible APIs: # http://pyqt.sourceforge.net/Docs/PyQt4/incompatible_apis.html _sip_apis = ["QDate", "QDateTime", "QString", "QTextStream", "QTime", "QUrl", "QVariant"] try: import sip except ImportError: pass else: for _sip_api in _sip_apis: try: sip.setapi(_sip_api, api) except ValueError: pass from PyQt4 import QtCore, QtGui __version__ = QtCore.PYQT_VERSION_STR # PyQt 4.6 introduced getSaveFileNameAndFilter: # https://riverbankcomputing.com/news/pyqt-46 if __version__ < LooseVersion("4.6"): raise ImportError("PyQt<4.6 is not supported") QtCore.Signal = QtCore.pyqtSignal QtCore.Slot = QtCore.pyqtSlot QtCore.Property = QtCore.pyqtProperty _getSaveFileName = QtGui.QFileDialog.getSaveFileNameAndFilter if QT_API == QT_API_PYQTv2: _setup_pyqt4_internal(api=2) elif QT_API == QT_API_PYSIDE: from PySide import QtCore, QtGui, __version__, __version_info__ # PySide 1.0.3 fixed the following: # https://srinikom.github.io/pyside-bz-archive/809.html if __version_info__ < (1, 0, 3): raise ImportError("PySide<1.0.3 is not supported") _getSaveFileName = QtGui.QFileDialog.getSaveFileName elif QT_API == QT_API_PYQT: _setup_pyqt4_internal(api=1) else: raise ValueError("Unexpected value for the 'backend.qt4' rcparam") QtWidgets = QtGui def is_pyqt5(): return False
Example #27
Source File: qt_compat.py From CogAlg with MIT License | 2 votes |
def _setup_pyqt4(): global QtCore, QtGui, QtWidgets, __version__, is_pyqt5, _getSaveFileName def _setup_pyqt4_internal(api): global QtCore, QtGui, QtWidgets, \ __version__, is_pyqt5, _getSaveFileName # List of incompatible APIs: # http://pyqt.sourceforge.net/Docs/PyQt4/incompatible_apis.html _sip_apis = ["QDate", "QDateTime", "QString", "QTextStream", "QTime", "QUrl", "QVariant"] try: import sip except ImportError: pass else: for _sip_api in _sip_apis: try: sip.setapi(_sip_api, api) except ValueError: pass from PyQt4 import QtCore, QtGui __version__ = QtCore.PYQT_VERSION_STR # PyQt 4.6 introduced getSaveFileNameAndFilter: # https://riverbankcomputing.com/news/pyqt-46 if __version__ < LooseVersion("4.6"): raise ImportError("PyQt<4.6 is not supported") QtCore.Signal = QtCore.pyqtSignal QtCore.Slot = QtCore.pyqtSlot QtCore.Property = QtCore.pyqtProperty _getSaveFileName = QtGui.QFileDialog.getSaveFileNameAndFilter if QT_API == QT_API_PYQTv2: _setup_pyqt4_internal(api=2) elif QT_API == QT_API_PYSIDE: from PySide import QtCore, QtGui, __version__, __version_info__ # PySide 1.0.3 fixed the following: # https://srinikom.github.io/pyside-bz-archive/809.html if __version_info__ < (1, 0, 3): raise ImportError("PySide<1.0.3 is not supported") _getSaveFileName = QtGui.QFileDialog.getSaveFileName elif QT_API == QT_API_PYQT: _setup_pyqt4_internal(api=1) else: raise ValueError("Unexpected value for the 'backend.qt4' rcparam") QtWidgets = QtGui def is_pyqt5(): return False
Example #28
Source File: qt_compat.py From twitter-stock-recommendation with MIT License | 2 votes |
def _setup_pyqt4(): global QtCore, QtGui, QtWidgets, __version__, is_pyqt5, _getSaveFileName def _setup_pyqt4_internal(api): global QtCore, QtGui, QtWidgets, \ __version__, is_pyqt5, _getSaveFileName # List of incompatible APIs: # http://pyqt.sourceforge.net/Docs/PyQt4/incompatible_apis.html _sip_apis = ["QDate", "QDateTime", "QString", "QTextStream", "QTime", "QUrl", "QVariant"] try: import sip except ImportError: pass else: for _sip_api in _sip_apis: try: sip.setapi(_sip_api, api) except ValueError: pass from PyQt4 import QtCore, QtGui __version__ = QtCore.PYQT_VERSION_STR # PyQt 4.6 introduced getSaveFileNameAndFilter: # https://riverbankcomputing.com/news/pyqt-46 if __version__ < LooseVersion("4.6"): raise ImportError("PyQt<4.6 is not supported") QtCore.Signal = QtCore.pyqtSignal QtCore.Slot = QtCore.pyqtSlot QtCore.Property = QtCore.pyqtProperty _getSaveFileName = QtGui.QFileDialog.getSaveFileNameAndFilter if QT_API == QT_API_PYQTv2: _setup_pyqt4_internal(api=2) elif QT_API == QT_API_PYSIDE: from PySide import QtCore, QtGui, __version__, __version_info__ # PySide 1.0.3 fixed the following: # https://srinikom.github.io/pyside-bz-archive/809.html if __version_info__ < (1, 0, 3): raise ImportError("PySide<1.0.3 is not supported") _getSaveFileName = QtGui.QFileDialog.getSaveFileName elif QT_API == QT_API_PYQT: _setup_pyqt4_internal(api=1) else: raise ValueError("Unexpected value for the 'backend.qt4' rcparam") QtWidgets = QtGui def is_pyqt5(): return False