當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。