当前位置: 首页>>代码示例>>Python>>正文


Python PyQt4.QtGui方法代码示例

本文整理汇总了Python中PyQt4.QtGui方法的典型用法代码示例。如果您正苦于以下问题:Python PyQt4.QtGui方法的具体用法?Python PyQt4.QtGui怎么用?Python PyQt4.QtGui使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4的用法示例。


在下文中一共展示了PyQt4.QtGui方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _setup_pyqt5

# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 import QtGui [as 别名]
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 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:19,代码来源:qt_compat.py

示例2: new_load_qt

# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 import QtGui [as 别名]
def new_load_qt(api):
    """
    Directly import the Qt libraries rather than autodiscovering them
    """
    from PyQt4 import QtCore, QtGui, QtSvg
    return QtCore, QtGui, QtSvg, 'pyqt' 
开发者ID:iris-edu,项目名称:pyweed,代码行数:8,代码来源:qtconsole.py

示例3: has_binding

# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 import QtGui [as 别名]
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'}
    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 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:40,代码来源:qt_loaders.py

示例4: import_pyqt4

# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 import QtGui [as 别名]
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 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:37,代码来源:qt_loaders.py

示例5: import_pyside

# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 import QtGui [as 别名]
def import_pyside():
    """
    Import PySide

    ImportErrors raised within this function are non-recoverable
    """
    from PySide import QtGui, QtCore, QtSvg
    return QtCore, QtGui, QtSvg, QT_API_PYSIDE 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:10,代码来源:qt_loaders.py

示例6: has_binding

# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 import QtGui [as 别名]
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 
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:42,代码来源:qt_loaders.py

示例7: import_pyqt4

# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 import QtGui [as 别名]
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 
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:37,代码来源:qt_loaders.py

示例8: import_pyqt5

# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 import QtGui [as 别名]
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 
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:15,代码来源:qt_loaders.py

示例9: import_pyside

# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 import QtGui [as 别名]
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 
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:10,代码来源:qt_loaders.py

示例10: _getSaveFileName

# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 import QtGui [as 别名]
def _getSaveFileName(*args, **kwargs):
                    return (QtGui.QFileDialog.getSaveFileName(*args, **kwargs),
                            None) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:5,代码来源:qt_compat.py

示例11: _pyside_as_qt_object

# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 import QtGui [as 别名]
def _pyside_as_qt_object(widget):
    from PySide.QtCore import QObject
    from PySide.QtGui import QWidget
    from PySide import QtGui
    from shiboken import wrapInstance
    if hasattr(widget, '__qt_object__'):
        return widget.__qt_object__
    ptr = _find_widget_ptr(widget)
    qobject = wrapInstance(long(ptr), QObject)
    meta = qobject.metaObject()
    _class = meta.className()
    _super = meta.superClass().className()
    qclass = getattr(QtGui, _class, getattr(QtGui, _super, QWidget))
    return wrapInstance(long(ptr), qclass) 
开发者ID:theodox,项目名称:mGui,代码行数:16,代码来源:_compat.py

示例12: _pyqt4_as_qt_object

# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 import QtGui [as 别名]
def _pyqt4_as_qt_object(widget):
    from sip import wrapinstance
    # Seting to api level 2 to better align with PySide behavior.
    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)
    from PyQt4.QtGui import QWidget
    if hasattr(widget, '__qt_object__'):
        return widget.__qt_object__
    ptr = _find_widget_ptr(widget)
    return wrapinstance(long(ptr), QWidget) 
开发者ID:theodox,项目名称:mGui,代码行数:17,代码来源:_compat.py

示例13: _setup_pyqt4

# 需要导入模块: import PyQt4 [as 别名]
# 或者: from PyQt4 import QtGui [as 别名]
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 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:50,代码来源:qt_compat.py


注:本文中的PyQt4.QtGui方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。