我们从Python开源项目中,提取了以下10个代码示例,用于说明如何使用PyQt5.QtCore.QT_VERSION_STR。
def printAbout(self): """ Show window with about and version information. """ msgBox = QMessageBox(QMessageBox.Information, "About", "About <b>" + basics.NAME + "</b>: <br><br>" + basics.NAME + " " + "is a file encryption and decryption tool using a Trezor hardware " "device for safety and security. Symmetric AES cryptography is used " "at its core. <br><br>" + "<b>" + basics.NAME + " Version: </b>" + basics.VERSION_STR + " from " + basics.VERSION_DATE_STR + "<br><br><b>Python Version: </b>" + sys.version.replace(" \n", "; ") + "<br><br><b>Qt Version: </b>" + QT_VERSION_STR + "<br><br><b>PyQt Version: </b>" + PYQT_VERSION_STR) msgBox.setIconPixmap(QPixmap(basics.LOGO_IMAGE)) msgBox.exec_()
def pyqt5(): import PyQt5.Qt from PyQt5 import QtCore, uic remap(QtCore, "Signal", QtCore.pyqtSignal) remap(QtCore, "Slot", QtCore.pyqtSlot) remap(QtCore, "Property", QtCore.pyqtProperty) add(PyQt5, "__wrapper_version__", __version__) add(PyQt5, "__binding__", "PyQt5") add(PyQt5, "__binding_version__", QtCore.PYQT_VERSION_STR) add(PyQt5, "__qt_version__", QtCore.QT_VERSION_STR, safe=False) add(PyQt5, "__added__", __added__) add(PyQt5, "__remapped__", __remapped__) add(PyQt5, "__modified__", __modified__) add(PyQt5, "load_ui", lambda fname: uic.loadUi(fname)) return PyQt5
def appActionAbout( self ): all_about_info = [] all_about_info.append( '%s %d.%d.%d' % (' '.join( self.app.app_name_parts ) ,wb_scm_version.major ,wb_scm_version.minor ,wb_scm_version.patch) ) all_about_info.append( '(%s)' % (wb_scm_version.commit,) ) all_about_info.append( '' ) all_about_info.append( 'Python %d.%d.%d %s %d' % (sys.version_info.major ,sys.version_info.minor ,sys.version_info.micro ,sys.version_info.releaselevel ,sys.version_info.serial) ) all_about_info.append( 'PyQt %s, Qt %s' % (Qt.PYQT_VERSION_STR, QtCore.QT_VERSION_STR) ) for scm_type in self.all_ui_components: all_about_info.append( '' ) all_about_info.extend( self.all_ui_components[ scm_type ].about() ) all_about_info.append( '' ) all_about_info.append( T_('Copyright Barry Scott (c) %s. All rights reserved') % (wb_scm_version.copyright_years,) ) box = QtWidgets.QMessageBox( QtWidgets.QMessageBox.Information, T_('About %s') % (' '.join( self.app.app_name_parts ),), '\n'.join( all_about_info ), QtWidgets.QMessageBox.Close, parent=self ) box.exec_()
def printVersion(self): print(u"%s Version: %s (%s)" % (basics.NAME, basics.VERSION_STR, basics.VERSION_DATE_STR)) print(u"Python: %s" % sys.version.replace(" \n", "; ")) print(u"Qt Version: %s" % QT_VERSION_STR) print(u"PyQt Version: %s" % PYQT_VERSION_STR)
def CanvasObject(): if g.config.mode3d: QtVersion = QtCore.QT_VERSION_STR.split(".") if not (int(QtVersion[0]) >= 5 and int(QtVersion[1]) >= 4): raise Exception("For the 3d mode you need a PyQt version that includes a Qt version of at least 5.4.\n" "Set mode3d to False in the config file, or update your PyQt version.\n" "Current version found: PyQt%s (which includes Qt%s)" % (QtCore.PYQT_VERSION_STR, QtCore.QT_VERSION_STR)) from PyQt5.QtWidgets import QOpenGLWidget return QOpenGLWidget else: return QGraphicsView
def backend_pyqt4_internal_check(self): try: from PyQt4 import QtCore except ImportError: raise CheckFailed("PyQt4 not found") try: qt_version = QtCore.QT_VERSION pyqt_version_str = QtCore.QT_VERSION_STR except AttributeError: raise CheckFailed('PyQt4 not correctly imported') else: return ("Qt: %s, PyQt: %s" % (self.convert_qt_version(qt_version), pyqt_version_str))
def backend_qt5_internal_check(self): try: from PyQt5 import QtCore except ImportError: raise CheckFailed("PyQt5 not found") try: qt_version = QtCore.QT_VERSION pyqt_version_str = QtCore.QT_VERSION_STR except AttributeError: raise CheckFailed('PyQt5 not correctly imported') else: return ("Qt: %s, PyQt: %s" % (self.convert_qt_version(qt_version), pyqt_version_str))
def version_info(): "Returns a human readable multi-line string containting the program's version information" try: from PyQt5.QtCore import QT_VERSION_STR gui_version = "PyQt5 Version: {0}".format(QT_VERSION_STR) except: gui_version = "PyQt5 Not Installed!" return "{program} ({locale}/{encoding})\nPython Version: {python_version}\n{gui_version}\n".format( program=full_version(), locale=locale.getdefaultlocale()[0], encoding=locale.getpreferredencoding(), python_version=sys.version[:3], gui_version=gui_version )
def about(self): import platform if use_pyside: Qt_version = QtCore.__version__ PyQt_version = PySide.__version__ else: Qt_version = QtCore.QT_VERSION_STR PyQt_version = QtCore.PYQT_VERSION_STR QMessageBox.about( self, "About XAFSmassQt", """<b>XAFSmass(Qt)</b> v {0} <ul> <li>{1[0]} <li>{1[1]} </ul> <p>Open source, {2}. Available at PyPI and GitHub<p> <p>Your system: <ul> <li>{3} <li>Python {4} <li>Qt {5} <li>{6} {7} </ul>""".format( __version__, __author__.split(','), __license__, platform.platform(terse=True), platform.python_version(), Qt_version, QtName, PyQt_version))
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, "__wrapper_version__", __version__) add(PyQt4, "__binding__", "PyQt4") add(PyQt4, "__binding_version__", QtCore.PYQT_VERSION_STR) add(PyQt4, "__qt_version__", QtCore.QT_VERSION_STR) add(PyQt4, "__added__", __added__) add(PyQt4, "__remapped__", __remapped__) add(PyQt4, "__modified__", __modified__) add(PyQt4, "load_ui", lambda fname: uic.loadUi(fname)) return PyQt4