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


Python PyQt5.QtWidgets方法代码示例

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


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

示例1: _setup_pyqt5

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

# 需要导入模块: import PyQt5 [as 别名]
# 或者: from PyQt5 import QtWidgets [as 别名]
def refreshMergedModList(self):
        self.mergedModList.clear()
        for modName in sorted(self.__mergedModInfo):
            modPluginsState = self.getMergedModPluginsState(modName)
            color = {
                Dc.ModPluginsState.UNKNOWN: Dc.red,
                Dc.ModPluginsState.ACTIVE: None,
                Dc.ModPluginsState.MIXED: Dc.yellow,
                Dc.ModPluginsState.INACTIVE: Dc.green
            }[modPluginsState]
            stateDescription = {
                Dc.ModPluginsState.UNKNOWN: self.__tr("Unknown"),
                Dc.ModPluginsState.ACTIVE: self.__tr("All plugins active"),
                Dc.ModPluginsState.MIXED: self.__tr("Some plugins active"),
                Dc.ModPluginsState.INACTIVE: self.__tr("All plugins inactive")
            }[modPluginsState]
            item = QtWidgets.QTreeWidgetItem(self.mergedModList, [modName, stateDescription])
            for x in range(2):
                if color:
                    item.setBackground(x, color)
                    item.setForeground(x, Qt.black)
                item.setData(x, Qt.UserRole, {"modName": modName, "modPluginsState": modPluginsState})
            self.mergedModList.addTopLevelItem(item)
        self.mergedModList.resizeColumnToContents(0) 
开发者ID:deorder,项目名称:mo2-plugins,代码行数:26,代码来源:mergePluginsHide.py

示例4: _pyside2_as_qt_object

# 需要导入模块: import PyQt5 [as 别名]
# 或者: from PyQt5 import QtWidgets [as 别名]
def _pyside2_as_qt_object(widget):
    from PySide2.QtCore import QObject
    from PySide2.QtWidgets import QWidget
    from PySide2 import QtWidgets
    from shiboken2 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(QtWidgets, _class, getattr(QtWidgets, _super, QWidget))
    return wrapInstance(long(ptr), qclass) 
开发者ID:theodox,项目名称:mGui,代码行数:16,代码来源:_compat.py

示例5: _pyqt5_as_qt_object

# 需要导入模块: import PyQt5 [as 别名]
# 或者: from PyQt5 import QtWidgets [as 别名]
def _pyqt5_as_qt_object(widget):
    from PyQt5.QtWidgets import QWidget
    from sip import wrapinstance
    if hasattr(widget, '__qt_object__'):
        return widget.__qt_object__
    ptr = _find_widget_ptr(widget)
    return wrapinstance(long(ptr), QWidget) 
开发者ID:theodox,项目名称:mGui,代码行数:9,代码来源:_compat.py

示例6: _translate

# 需要导入模块: import PyQt5 [as 别名]
# 或者: from PyQt5 import QtWidgets [as 别名]
def _translate(context, text, disambig):
        return QtWidgets.QApplication.translate(context, text,
                disambig, _encoding) 
开发者ID:techbliss,项目名称:Python_editor,代码行数:5,代码来源:pyeditor.py

示例7: open

# 需要导入模块: import PyQt5 [as 别名]
# 或者: from PyQt5 import QtWidgets [as 别名]
def open(self):
        self.path = QtCore.QFileInfo(self.filename).path()

        # Get filename and show only .writer files
        (self.filename, _) = \
            QtWidgets.QFileDialog.getOpenFileName(self.vindu,
                'Open File', self.path,
                'Python Files (*.py *.pyc *.pyw)', '')

        if self.filename:
            with open(self.filename, 'r') as self.file:
                self.codebox.setText(self.file.read())
        os.chdir(str(self.path)) 
开发者ID:techbliss,项目名称:Python_editor,代码行数:15,代码来源:pyeditor.py

示例8: savefile

# 需要导入模块: import PyQt5 [as 别名]
# 或者: from PyQt5 import QtWidgets [as 别名]
def savefile(self):
        self.path = QtCore.QFileInfo(self.filename).path()
        (self.filename, _) = \
            QtWidgets.QFileDialog.getSaveFileName(self.vindu, 'Save as'
                , self.path, 'Python Files (*.py *.pyc *.pyw)')
        if self.filename:
            self.savetext(self.filename)
        os.chdir(str(self.path)) 
开发者ID:techbliss,项目名称:Python_editor,代码行数:10,代码来源:pyeditor.py

示例9: savetext

# 需要导入模块: import PyQt5 [as 别名]
# 或者: from PyQt5 import QtWidgets [as 别名]
def savetext(self, fileName):
        textout = self.codebox.text()
        file = QtCore.QFile(fileName)
        if file.open(QtCore.QIODevice.WriteOnly):
            QtCore.QTextStream(file) << textout
        else:
            QtWidgets.QMessageBox.information(self.vindu,
                    'Unable to open file', file.errorString())
        os.chdir(str(self.path)) 
开发者ID:techbliss,项目名称:Python_editor,代码行数:11,代码来源:pyeditor.py

示例10: opentemp

# 需要导入模块: import PyQt5 [as 别名]
# 或者: from PyQt5 import QtWidgets [as 别名]
def opentemp(self):
        print "hello"
        self.path = QtCore.QFileInfo(self.filename).path()

        # Get filename and show only .writer files
        (self.filename, _) = \
            QtWidgets.QFileDialog.getOpenFileName(self.wizardPage_3,
                'Open File', self.path,
                'Python Files (*.py *.pyc *.pyw)', '')

        if self.filename:
            with open(self.filename, 'r') as self.file:
                self.TemptextEdit.setText(self.file.read())
        os.chdir(str(self.path)) 
开发者ID:techbliss,项目名称:Python_editor,代码行数:16,代码来源:pyeditor.py

示例11: savetemp

# 需要导入模块: import PyQt5 [as 别名]
# 或者: from PyQt5 import QtWidgets [as 别名]
def savetemp(self):
        self.path = QtCore.QFileInfo(self.filename).path()
        (self.filename, _) = \
            QtWidgets.QFileDialog.getSaveFileName(self, 'Save as'
                , self.path, 'Python Files (*.py *.pyc *.pyw)')
        if self.filename:
            self.savetexttemp(self.filename)
        os.chdir(str(self.path)) 
开发者ID:techbliss,项目名称:Python_editor,代码行数:10,代码来源:pyeditor.py

示例12: openscript

# 需要导入模块: import PyQt5 [as 别名]
# 或者: from PyQt5 import QtWidgets [as 别名]
def openscript(self):
        print "hello"
        self.path = QtCore.QFileInfo(self.filename).path()

        # Get filename and show only .writer files
        (self.filename, _) = \
            QtWidgets.QFileDialog.getOpenFileName(self.wizardPage_3,
                'Open File', self.path,
                'Python Files (*.py *.pyc *.pyw)', '')

        if self.filename:
            with open(self.filename, 'r') as self.file:
                self.script_textEdit.setText(self.file.read())
        os.chdir(str(self.path)) 
开发者ID:techbliss,项目名称:Python_editor,代码行数:16,代码来源:pyeditor.py

示例13: savescript

# 需要导入模块: import PyQt5 [as 别名]
# 或者: from PyQt5 import QtWidgets [as 别名]
def savescript(self):
        self.path = QtCore.QFileInfo(self.filename).path()
        (self.filename, _) = \
            QtWidgets.QFileDialog.getSaveFileName(self.wizardPage_3, 'Save as'
                , self.path, 'Python Files (*.py *.pyc *.pyw)')
        if self.filename:
            self.savetextscript(self.filename)
        os.chdir(str(self.path)) 
开发者ID:techbliss,项目名称:Python_editor,代码行数:10,代码来源:pyeditor.py

示例14: savetextscript

# 需要导入模块: import PyQt5 [as 别名]
# 或者: from PyQt5 import QtWidgets [as 别名]
def savetextscript(self, fileName):
        textout = self.script_textEdit.text()
        file = QtCore.QFile(fileName)
        if file.open(QtCore.QIODevice.WriteOnly):
            QtCore.QTextStream(file) << textout
        else:
            QtWidgets.QMessageBox.information(self.wizardPage_3,
                    'Unable to open file', file.errorString())
        os.chdir(str(self.path)) 
开发者ID:techbliss,项目名称:Python_editor,代码行数:11,代码来源:pyeditor.py

示例15: font_choice

# 需要导入模块: import PyQt5 [as 别名]
# 或者: from PyQt5 import QtWidgets [as 别名]
def font_choice(self):
        self.lbl = self.lexer
        font, ok = QtWidgets.QFontDialog.getFont()
        if ok:
            self.lbl.setFont(font) 
开发者ID:techbliss,项目名称:Python_editor,代码行数:7,代码来源:pyeditor.py


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