Python PyQt4 模块,QtGui() 实例源码

我们从Python开源项目中,提取了以下12个代码示例,用于说明如何使用PyQt4.QtGui()

项目:mgear    作者:miquelcampos    | 项目源码 | 文件源码
def qt_import(shi=False, cui=False):
    """
    import pyside/pyQt

    Returns:
        multi: QtGui, QtCore, QtWidgets, wrapInstance

    """
    lookup = ["PySide2", "PySide", "PyQt4"]

    preferredBinding = os.environ.get("MGEAR_PYTHON_QT_BINDING", None)
    if preferredBinding is not None and preferredBinding in lookup:
        lookup.remove(preferredBinding)
        lookup.insert(0, preferredBinding)

    for binding in lookup:
        try:
            return _qt_import(binding, shi, cui)
        except Exception:
            pass

    raise _qt_import("ThisBindingSurelyDoesNotExist", False, False)
项目:specto    作者:mrknow    | 项目源码 | 文件源码
def import_pyqt5():
    """
    Import PyQt5

    ImportErrors raised within this function are non-recoverable
    """
    from PyQt5 import QtGui, QtCore, QtSvg

    # Alias PyQt-specific functions for PySide compatibility.
    QtCore.Signal = QtCore.pyqtSignal
    QtCore.Slot = QtCore.pyqtSlot

    return QtCore, QtGui, QtSvg, QT_API_PYQT5
项目:OrderScaner    作者:Nikakto    | 项目源码 | 文件源码
def __init__(self):

        super(trayMassanger, self).__init__()

        self.scaning = 0
        self.iconScaning = QtGui.QMovie("images/iconScaning.GIF")
        self.iconScaning.frameChanged.connect(self.iconUpdate)

            # alarm settings
        self.alarmWithSound = 1
        self.alarmWAV = QSound("sounds/alarm2.WAV")

            # tray settings
        self.tray = QtGui.QSystemTrayIcon()

        self.iconScaning.jumpToFrame(0)
        icon = QtGui.QIcon()
        icon.addPixmap(self.iconScaning.currentPixmap())
        self.tray.setIcon(icon)        

        self.tray.show()

        print(self.iconScaning.isValid())
项目:mgear    作者:miquelcampos    | 项目源码 | 文件源码
def _qt_import(binding, shi=False, cui=False):
    QtGui = None
    QtCore = None
    QtWidgets = None
    wrapInstance = None

    if binding == "PySide2":
        from PySide2 import QtGui, QtCore, QtWidgets
        import shiboken2 as shiboken
        from shiboken2 import wrapInstance
        from pyside2uic import compileUi

    elif binding == "PySide":
        from PySide import QtGui, QtCore
        import PySide.QtGui as QtWidgets
        import shiboken
        from shiboken import wrapInstance
        from pysideuic import compileUi

    elif binding == "PyQt4":
        from PyQt4 import QtGui
        from PyQt4 import QtCore
        import PyQt4.QtGui as QtWidgets
        from sip import wrapinstance as wrapInstance
        from PyQt4.uic import compileUi
        print("Warning: 'shiboken' is not supported in 'PyQt4' Qt binding")
        shiboken = None

    else:
        raise Exception("Unsupported python Qt binding '%s'" % binding)

    rv = [QtGui, QtCore, QtWidgets, wrapInstance]
    if shi:
        rv.append(shiboken)
    if cui:
        rv.append(compileUi)
    return rv
项目:driveboardapp    作者:nortd    | 项目源码 | 文件源码
def test_PyQt4_QtWebKit(pyi_builder):
    pyi_builder.test_source(
        """
        from PyQt4.QtGui import QApplication
        from PyQt4.QtWebKit import QWebView
        from PyQt4.QtCore import QTimer

        app = QApplication([])
        view = QWebView()
        view.show()
        # Exit Qt when the main loop becomes idle.
        QTimer.singleShot(0, app.exit)
        # Run the main loop, displaying the WebKit widget.
        app.exec_()
        """)
项目:specto    作者:mrknow    | 项目源码 | 文件源码
def has_binding(api):
    """Safely check for PyQt4 or PySide, without importing
       submodules

       Parameters
       ----------
       api : str [ 'pyqtv1' | 'pyqt' | 'pyside' | '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 = {QT_API_PYSIDE: 'PySide',
                   QT_API_PYQT: 'PyQt4',
                   QT_API_PYQTv1: 'PyQt4',
                   QT_API_PYQT_DEFAULT: 'PyQt4',
                   QT_API_PYQT5: 'PyQt5',
                   }
    module_name = module_name[api]

    import imp
    try:
        #importing top level PyQt4/PySide module is ok...
        mod = __import__(module_name)
        #...importing submodules is not
        imp.find_module('QtCore', mod.__path__)
        imp.find_module('QtGui', mod.__path__)
        imp.find_module('QtSvg', 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
项目:specto    作者:mrknow    | 项目源码 | 文件源码
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
项目:specto    作者:mrknow    | 项目源码 | 文件源码
def import_pyside():
    """
    Import PySide

    ImportErrors raised within this function are non-recoverable
    """
    from PySide import QtGui, QtCore, QtSvg  # @UnresolvedImport
    return QtCore, QtGui, QtSvg, QT_API_PYSIDE
项目:mac-package-build    作者:persepolisdm    | 项目源码 | 文件源码
def test_PyQt4_QtWebKit(pyi_builder):
    pyi_builder.test_source(
        """
        from PyQt4.QtGui import QApplication
        from PyQt4.QtWebKit import QWebView
        from PyQt4.QtCore import QTimer

        app = QApplication([])
        view = QWebView()
        view.show()
        # Exit Qt when the main loop becomes idle.
        QTimer.singleShot(0, app.exit)
        # Run the main loop, displaying the WebKit widget.
        app.exec_()
        """)
项目:OrderScaner    作者:Nikakto    | 项目源码 | 文件源码
def settings_newPath(self):

        newPath = PyQt4.QtGui.QFileDialog.getExistingDirectory(self, "Open Directory", self.path,
                                                               QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks)

        if len(newPath):
            self.path = newPath.replace('\\','/') + '/'
            self.LE_Path.setText( self.path )
项目:OrderScaner    作者:Nikakto    | 项目源码 | 文件源码
def setScaning(self, scaning):

        self.scaning = scaning

        if self.scaning:
            self.iconScaning.start()
            self.iconScaning.jumpToFrame(0)
        else:
            self.iconScaning.stop()
            self.iconScaning.jumpToFrame(0)

        icon = QtGui.QIcon()
        icon.addPixmap(self.iconScaning.currentPixmap())
        self.tray.setIcon(icon)
项目:OrderScaner    作者:Nikakto    | 项目源码 | 文件源码
def iconUpdate(self):

        if not self.scaning:
            self.iconScaning.stop()
            self.iconScaning.jumpToFrame(0)

        icon = QtGui.QIcon()
        icon.addPixmap(self.iconScaning.currentPixmap())
        self.tray.setIcon(icon)