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


Python PyQt5.QtGui方法代码示例

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


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

示例1: _setup_pyqt5

# 需要导入模块: import PyQt5 [as 别名]
# 或者: from PyQt5 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: setupUi1

# 需要导入模块: import PyQt5 [as 别名]
# 或者: from PyQt5 import QtGui [as 别名]
def setupUi1(self, messageformForm):
        messageformForm.setObjectName("messageformForm")
        messageformForm.resize(404, 169)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(messageformForm.sizePolicy().hasHeightForWidth())
        messageformForm.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Consolas")
        messageformForm.setFont(font)
        icon2 = QtGui.QIcon()
        icon2.addPixmap(QtGui.QPixmap(":/icons/twa.gif"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        messageformForm.setWindowIcon(icon2)
        self.label = QtWidgets.QLabel(messageformForm)
        self.label.setGeometry(QtCore.QRect(40, 20, 341, 111))
        font = QtGui.QFont()
        font.setPointSize(19)
        self.label.setFont(font)
        self.label.setObjectName("label")

        self.retranslateUi(messageformForm)
        QtCore.QMetaObject.connectSlotsByName(messageformForm) 
开发者ID:techbliss,项目名称:Python_editor,代码行数:25,代码来源:pyeditor.py

示例3: has_binding

# 需要导入模块: import PyQt5 [as 别名]
# 或者: from PyQt5 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

示例4: import_pyqt4

# 需要导入模块: import PyQt5 [as 别名]
# 或者: from PyQt5 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

示例5: import_pyqt5

# 需要导入模块: import PyQt5 [as 别名]
# 或者: from PyQt5 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

示例6: import_pyside

# 需要导入模块: import PyQt5 [as 别名]
# 或者: from PyQt5 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

示例7: moveCursor

# 需要导入模块: import PyQt5 [as 别名]
# 或者: from PyQt5 import QtGui [as 别名]
def moveCursor(self,start,end):

        # We retrieve the QTextCursor object from the parent's QTextEdit
        cursor = self.parent.text.textCursor()

        # Then we set the position to the beginning of the last match
        cursor.setPosition(start)

        # Next we move the Cursor by over the match and pass the KeepAnchor parameter
        # which will make the cursor select the the match's text
        cursor.movePosition(QtGui.QTextCursor.Right,QtGui.QTextCursor.KeepAnchor,end - start)

        # And finally we set this new cursor as the parent's 
        self.parent.text.setTextCursor(cursor) 
开发者ID:goldsborough,项目名称:Writer-Tutorial,代码行数:16,代码来源:find.py

示例8: _getSaveFileName

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

示例9: _pyside_as_qt_object

# 需要导入模块: import PyQt5 [as 别名]
# 或者: from PyQt5 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

示例10: _pyqt4_as_qt_object

# 需要导入模块: import PyQt5 [as 别名]
# 或者: from PyQt5 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

示例11: __init__

# 需要导入模块: import PyQt5 [as 别名]
# 或者: from PyQt5 import QtGui [as 别名]
def __init__(self, package):
        UIParser.__init__(self, QtCore, QtGui, QtWidgets, LoaderCreatorPolicy(package)) 
开发者ID:techbliss,项目名称:Python_editor,代码行数:4,代码来源:loader.py

示例12: show_camera

# 需要导入模块: import PyQt5 [as 别名]
# 或者: from PyQt5 import QtGui [as 别名]
def show_camera(self):
        flag, self.camera_image = self.cap.read()
        show = cv2.resize(self.image, (640, 480))
        show = cv2.cvtColor(show, cv2.COLOR_BGR2RGB)
        showImage = QtGui.QImage(show.data, show.shape[1], show.shape[0], QtGui.QImage.Format_RGB888)
        self.label_show_camera.setPixmap(QtGui.QPixmap.fromImage(showImage))

# 初始化 
开发者ID:PerpetualSmile,项目名称:BeautyCamera,代码行数:10,代码来源:main.py

示例13: icon

# 需要导入模块: import PyQt5 [as 别名]
# 或者: from PyQt5 import QtGui [as 别名]
def icon(self):
        return QtGui.QIcon(':/deorder/mergePluginsHide') 
开发者ID:deorder,项目名称:mo2-plugins,代码行数:4,代码来源:mergePluginsHide.py

示例14: openProfileMenu

# 需要导入模块: import PyQt5 [as 别名]
# 或者: from PyQt5 import QtGui [as 别名]
def openProfileMenu(self, position):
        selectedItems = self.profileList.selectedItems()
        if selectedItems:
            menu = QtWidgets.QMenu()

            selectedItemsData = [item.data(0, Qt.UserRole) for item in selectedItems]
            selectedProfiles = [selectedItemData['profileName'] for selectedItemData in selectedItemsData]

            syncAction = QtWidgets.QAction(QtGui.QIcon(':/MO/gui/next'), self.__tr('&Sync mod order'), self)
            syncAction.setEnabled(True)
            menu.addAction(syncAction)

            action = menu.exec_(self.profileList.mapToGlobal(position))

            try:
                if action == syncAction:
                    for profileName in selectedProfiles:
                        profileInfo = self.__profileInfo[profileName]
                        modListPath = os.path.join(profileInfo['path'], 'modlist.txt')
                        modListBackupPath = modListPath + '.' +  datetime.datetime.now().strftime('%Y%m%d%H%M%S%f')

                        qDebug(self.__tr("Backing up to {}".format(modListBackupPath)).encode('utf-8'))
                        shutil.copy(modListPath, modListBackupPath)

                        selectedModListInfo = self.getModListInfoByPath(modListPath)
                        mergedModListInfo = dict(self.__modListInfo, **selectedModListInfo)

                        for modName in list(self.__modListInfo.keys()):
                            mergedModListInfo[modName]['index'] = self.__modListInfo[modName]['index']
                            
                        qDebug(self.__tr("Updating {} mod order".format(modListPath)).encode('utf-8'))
                        with open(modListPath, 'w', encoding='utf-8') as modListFile:
                            for modName, modListEntry in sorted(list(mergedModListInfo.items()), key=lambda x: x[1]['index']):
                                modListFile.write(modListEntry['symbol'] + modListEntry['name'] + '\n')
                                
                    self.refreshProfileList()
            except Exception as e:
                qCritical(str(e).encode('utf-8')) 
开发者ID:deorder,项目名称:mo2-plugins,代码行数:40,代码来源:syncModOrder.py

示例15: icon

# 需要导入模块: import PyQt5 [as 别名]
# 或者: from PyQt5 import QtGui [as 别名]
def icon(self):

        return QtGui.QIcon(':/deorder/syncModOrder') 
开发者ID:deorder,项目名称:mo2-plugins,代码行数:5,代码来源:syncModOrder.py


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