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


Python QtWidgets.QPushButton方法代码示例

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


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

示例1: setupUi

# 需要导入模块: from Qt import QtWidgets [as 别名]
# 或者: from Qt.QtWidgets import QPushButton [as 别名]
def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(228, 30)
        self.horizontalLayout = QtWidgets.QHBoxLayout(Form)
        self.horizontalLayout.setSpacing(1)
        self.horizontalLayout.setContentsMargins(1, 1, 1, 1)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.widget = QtWidgets.QWidget(Form)
        self.widget.setObjectName("widget")
        self.horizontalLayout.addWidget(self.widget)
        self.labelName = QtWidgets.QLabel(Form)
        self.labelName.setObjectName("labelName")
        self.horizontalLayout.addWidget(self.labelName)
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        self.pbKill = QtWidgets.QPushButton(Form)
        self.pbKill.setMaximumSize(QtCore.QSize(40, 16777215))
        self.pbKill.setText("")
        self.pbKill.setObjectName("pbKill")
        self.horizontalLayout.addWidget(self.pbKill)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form) 
开发者ID:wonderworks-software,项目名称:PyFlow,代码行数:25,代码来源:VariableForm_ui.py

示例2: test_qtcompat_base_class

# 需要导入模块: from Qt import QtWidgets [as 别名]
# 或者: from Qt.QtWidgets import QPushButton [as 别名]
def test_qtcompat_base_class():
    """Tests to ensure the QtCompat namespace object works as expected"""
    import sys
    import Qt
    from Qt import QtWidgets
    from Qt import QtCompat
    app = QtWidgets.QApplication(sys.argv)
    # suppress `local variable 'app' is assigned to but never used`
    app
    header = QtWidgets.QHeaderView(Qt.QtCore.Qt.Horizontal)

    # Spot check compatibility functions
    QtCompat.QHeaderView.setSectionsMovable(header, False)
    assert QtCompat.QHeaderView.sectionsMovable(header) is False
    QtCompat.QHeaderView.setSectionsMovable(header, True)
    assert QtCompat.QHeaderView.sectionsMovable(header) is True

    # Verify that the grab function actually generates a non-null image
    button = QtWidgets.QPushButton('TestImage')
    pixmap = QtCompat.QWidget.grab(button)
    assert not pixmap.isNull() 
开发者ID:mottosso,项目名称:Qt.py,代码行数:23,代码来源:tests.py

示例3: test_wrapInstance

# 需要导入模块: from Qt import QtWidgets [as 别名]
# 或者: from Qt.QtWidgets import QPushButton [as 别名]
def test_wrapInstance():
        """.wrapInstance and .getCppPointer is identical across all bindings"""
        from Qt import QtCompat, QtWidgets

        app = QtWidgets.QApplication(sys.argv)

        try:
            button = QtWidgets.QPushButton("Hello world")
            button.setObjectName("MySpecialButton")
            pointer = QtCompat.getCppPointer(button)
            widget = QtCompat.wrapInstance(long(pointer),
                                           QtWidgets.QWidget)
            assert isinstance(widget, QtWidgets.QWidget), widget
            assert widget.objectName() == button.objectName()

            # IMPORTANT: this differs across sip and shiboken.
            if binding("PySide") or binding("PySide2"):
                assert widget != button
            else:
                assert widget == button

        finally:
            app.exit() 
开发者ID:mottosso,项目名称:Qt.py,代码行数:25,代码来源:tests.py

示例4: setupUi

# 需要导入模块: from Qt import QtWidgets [as 别名]
# 或者: from Qt.QtWidgets import QPushButton [as 别名]
def setupUi(self, findReplace):
        findReplace.setObjectName("findReplace")
        findReplace.resize(246, 101)
        self.verticalLayout = QtWidgets.QVBoxLayout(findReplace)
        self.verticalLayout.setObjectName("verticalLayout")
        self.gridLayout = QtWidgets.QGridLayout()
        self.gridLayout.setObjectName("gridLayout")
        self.replace_le = QtWidgets.QLineEdit(findReplace)
        self.replace_le.setObjectName("replace_le")
        self.gridLayout.addWidget(self.replace_le, 1, 0, 1, 1)
        self.find_le = QtWidgets.QLineEdit(findReplace)
        self.find_le.setObjectName("find_le")
        self.gridLayout.addWidget(self.find_le, 0, 0, 1, 1)
        self.find_btn = QtWidgets.QPushButton(findReplace)
        self.find_btn.setObjectName("find_btn")
        self.gridLayout.addWidget(self.find_btn, 0, 1, 1, 1)
        self.replace_btn = QtWidgets.QPushButton(findReplace)
        self.replace_btn.setObjectName("replace_btn")
        self.gridLayout.addWidget(self.replace_btn, 1, 1, 1, 1)
        self.replaceAll_btn = QtWidgets.QPushButton(findReplace)
        self.replaceAll_btn.setObjectName("replaceAll_btn")
        self.gridLayout.addWidget(self.replaceAll_btn, 2, 1, 1, 1)
        self.verticalLayout.addLayout(self.gridLayout)

        self.retranslateUi(findReplace)
        QtCore.QMetaObject.connectSlotsByName(findReplace)
        findReplace.setTabOrder(self.find_le, self.replace_le)
        findReplace.setTabOrder(self.replace_le, self.find_btn)
        findReplace.setTabOrder(self.find_btn, self.replace_btn)
        findReplace.setTabOrder(self.replace_btn, self.replaceAll_btn) 
开发者ID:weijer,项目名称:NukeToolSet,代码行数:32,代码来源:findWidget_UIs.py

示例5: __init__

# 需要导入模块: from Qt import QtWidgets [as 别名]
# 或者: from Qt.QtWidgets import QPushButton [as 别名]
def __init__(self, parent=None):
        super(ReplacePath, self).__init__(parent)
        self.resize(500, 100)
        self.setWindowTitle('Replace Read Node Path')
        self.setWindowFlags(QtCore.Qt.Dialog | QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.WindowMinimizeButtonHint)
        main_layout = QtGui.QVBoxLayout(self)
        main_layout.setSpacing(15)

        source_label = QtGui.QLabel('Source Path')
        self.source_le = QtGui.QLineEdit()
        target_label = QtGui.QLabel('Target Path')
        self.target_le = QtGui.QLineEdit()
        self.replace_btn = QtGui.QPushButton('Replace')
        self.replace_btn.clicked.connect(self.do_replace)

        source_layout = QtGui.QHBoxLayout()
        source_layout.addWidget(source_label)
        source_layout.addWidget(self.source_le)

        target_layout = QtGui.QHBoxLayout()
        target_layout.addWidget(target_label)
        target_layout.addWidget(self.target_le)

        main_layout.addLayout(source_layout)
        main_layout.addLayout(target_layout)
        main_layout.addWidget(self.replace_btn) 
开发者ID:weijer,项目名称:NukeToolSet,代码行数:28,代码来源:replace_read_node_path.py

示例6: __makeWidgets

# 需要导入模块: from Qt import QtWidgets [as 别名]
# 或者: from Qt.QtWidgets import QPushButton [as 别名]
def __makeWidgets(self):
        main_layout = QtWidgets.QHBoxLayout()
        self.setLayout(main_layout)

        self.__back_button = QtWidgets.QPushButton()
        self.__next_button = QtWidgets.QPushButton()
        self.__back_button.setObjectName("medic_browser_back")
        self.__next_button.setObjectName("medic_browser_next")

        main_layout.addWidget(self.__back_button)
        main_layout.addWidget(self.__next_button)
        main_layout.setSpacing(1)

        self.__back_button.clicked.connect(self.BackClicked.emit)
        self.__next_button.clicked.connect(self.NextClicked.emit) 
开发者ID:sol-ansano-kim,项目名称:medic,代码行数:17,代码来源:widgets.py

示例7: __init__

# 需要导入模块: from Qt import QtWidgets [as 别名]
# 或者: from Qt.QtWidgets import QPushButton [as 别名]
def __init__(self, rawVariable, variablesWidget, parent=None):
        super(UIVariable, self).__init__(parent)
        self._rawVariable = rawVariable
        self.variablesWidget = variablesWidget
        # ui
        self.horizontalLayout = QHBoxLayout(self)
        self.horizontalLayout.setSpacing(1)
        self.horizontalLayout.setContentsMargins(1, 1, 1, 1)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.widget = TypeWidget(findPinClassByType(self._rawVariable.dataType).color(), self)
        self.widget.setObjectName("widget")
        self.horizontalLayout.addWidget(self.widget)
        self.labelName = QLabel(self)
        self.labelName.setStyleSheet("background:transparent")
        self.labelName.setObjectName("labelName")
        self.horizontalLayout.addWidget(self.labelName)
        spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        # find refs
        self.pbFindRefs = QPushButton("")
        self.pbFindRefs.setIcon(QtGui.QIcon(":/searching-magnifying-glass.png"))
        self.pbFindRefs.setObjectName("pbFindRefs")
        self.horizontalLayout.addWidget(self.pbFindRefs)
        self.pbFindRefs.clicked.connect(self.onFindRefsClicked)
        #  kill variable
        self.pbKill = QPushButton("")
        self.pbKill.setIcon(QtGui.QIcon(":/delete_icon.png"))
        self.pbKill.setObjectName("pbKill")
        self.horizontalLayout.addWidget(self.pbKill)
        self.pbKill.clicked.connect(self.onKillClicked)

        QtCore.QMetaObject.connectSlotsByName(self)
        self.setName(self._rawVariable.name)
        self._rawVariable.setWrapper(self) 
开发者ID:wonderworks-software,项目名称:PyFlow,代码行数:36,代码来源:UIVariable.py

示例8: setupUi

# 需要导入模块: from Qt import QtWidgets [as 别名]
# 或者: from Qt.QtWidgets import QPushButton [as 别名]
def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(341, 363)
        self.verticalLayout = QtWidgets.QVBoxLayout(Form)
        self.verticalLayout.setSpacing(1)
        self.verticalLayout.setContentsMargins(1, 1, 1, 1)
        self.verticalLayout.setObjectName("verticalLayout")
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.label = QtWidgets.QLabel(Form)
        self.label.setObjectName("label")
        self.horizontalLayout.addWidget(self.label)
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        self.pbNewVar = QtWidgets.QPushButton(Form)
        self.pbNewVar.setMaximumSize(QtCore.QSize(50, 16777215))
        self.pbNewVar.setObjectName("pbNewVar")
        self.horizontalLayout.addWidget(self.pbNewVar)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.wListWidget = QtWidgets.QWidget(Form)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.wListWidget.sizePolicy().hasHeightForWidth())
        self.wListWidget.setSizePolicy(sizePolicy)
        self.wListWidget.setObjectName("wListWidget")
        self.gridLayout = QtWidgets.QGridLayout(self.wListWidget)
        self.gridLayout.setContentsMargins(1, 1, 1, 1)
        self.gridLayout.setObjectName("gridLayout")
        self.lytListWidget = QtWidgets.QVBoxLayout()
        self.lytListWidget.setContentsMargins(0, 0, 0, 0)
        self.lytListWidget.setObjectName("lytListWidget")
        self.gridLayout.addLayout(self.lytListWidget, 0, 0, 1, 1)
        self.verticalLayout.addWidget(self.wListWidget)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form) 
开发者ID:wonderworks-software,项目名称:PyFlow,代码行数:39,代码来源:VariablesWidget_ui.py

示例9: test_import_from_qtwidgets

# 需要导入模块: from Qt import QtWidgets [as 别名]
# 或者: from Qt.QtWidgets import QPushButton [as 别名]
def test_import_from_qtwidgets():
    """Fix #133, `from Qt.QtWidgets import XXX` works"""
    from Qt.QtWidgets import QPushButton
    assert QPushButton.__name__ == "QPushButton", QPushButton 
开发者ID:mottosso,项目名称:Qt.py,代码行数:6,代码来源:tests.py

示例10: test_implicit_wrapInstance

# 需要导入模块: from Qt import QtWidgets [as 别名]
# 或者: from Qt.QtWidgets import QPushButton [as 别名]
def test_implicit_wrapInstance():
        """.wrapInstance doesn't need the `base` argument"""
        from Qt import QtCompat, QtWidgets

        app = QtWidgets.QApplication(sys.argv)

        try:
            button = QtWidgets.QPushButton("Hello world")
            button.setObjectName("MySpecialButton")
            pointer = QtCompat.getCppPointer(button)
            widget = QtCompat.wrapInstance(long(pointer))
            assert isinstance(widget, QtWidgets.QWidget), widget
            assert widget.objectName() == button.objectName()

            if binding("PySide"):
                assert widget != button
            elif binding("PySide2") and _pyside2_commit_date() is None:
                assert widget != button
            elif binding("PySide2") and \
                    _pyside2_commit_date() <= datetime.datetime(
                        2017, 8, 25):
                assert widget == button
            else:
                assert widget == button

        finally:
            app.exit() 
开发者ID:mottosso,项目名称:Qt.py,代码行数:29,代码来源:tests.py

示例11: setupUi

# 需要导入模块: from Qt import QtWidgets [as 别名]
# 或者: from Qt.QtWidgets import QPushButton [as 别名]
def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(465, 393)
        self.verticalLayout = QtWidgets.QVBoxLayout(Dialog)
        self.verticalLayout.setObjectName("verticalLayout")
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setContentsMargins(-1, 20, -1, 20)
        self.horizontalLayout.setObjectName("horizontalLayout")
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        self.icon_lb = QtWidgets.QLabel(Dialog)
        font = QtWidgets.QFont()
        font.setPointSize(20)
        self.icon_lb.setFont(font)
        self.icon_lb.setText("")
        self.icon_lb.setObjectName("icon_lb")
        self.horizontalLayout.addWidget(self.icon_lb)
        self.title_lb = QtWidgets.QLabel(Dialog)
        font = QtWidgets.QFont()
        font.setPointSize(20)
        self.title_lb.setFont(font)
        self.title_lb.setObjectName("title_lb")
        self.horizontalLayout.addWidget(self.title_lb)
        spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem1)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.text_link_lb = QtWidgets.QLabel(Dialog)
        self.text_link_lb.setObjectName("text_link_lb")
        self.verticalLayout.addWidget(self.text_link_lb)
        self.textBrowser = QtWidgets.QTextBrowser(Dialog)
        self.textBrowser.setObjectName("textBrowser")
        self.verticalLayout.addWidget(self.textBrowser)
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.donate_btn = QtWidgets.QPushButton(Dialog)
        self.donate_btn.setObjectName("donate_btn")
        self.horizontalLayout_2.addWidget(self.donate_btn)
        self.verticalLayout.addLayout(self.horizontalLayout_2)
        self.verticalLayout.setStretch(2, 1)

        self.retranslateUi(Dialog)
        QtCore.QMetaObject.connectSlotsByName(Dialog) 
开发者ID:weijer,项目名称:NukeToolSet,代码行数:44,代码来源:about_UIs.py

示例12: __createWidgets

# 需要导入模块: from Qt import QtWidgets [as 别名]
# 或者: from Qt.QtWidgets import QPushButton [as 别名]
def __createWidgets(self):
        main_layout = QtWidgets.QVBoxLayout()
        self.setLayout(main_layout)
        main_layout.setContentsMargins(0, 0, 0, 0)

        # frame
        frame = QtWidgets.QFrame()
        frame.setObjectName("detail_frame")
        main_layout.addWidget(frame)
        frame_layout = QtWidgets.QVBoxLayout()
        frame.setLayout(frame_layout)
        frame_layout.setContentsMargins(10, 10, 10, 10)

        # layout
        self.__qt_parameter_layout = QtWidgets.QVBoxLayout()
        button_layout = QtWidgets.QHBoxLayout()

        # widgets
        self.__qt_tester_label = QtWidgets.QLabel()
        self.__qt_description = QtWidgets.QTextEdit()
        self.__qt_description.setFixedHeight(50)
        self.__qt_description.setReadOnly(True)
        self.__qt_tester_label.setObjectName("detail_tester_label")
        self.__qt_description.setObjectName("detail_tester_description")
        self.__qt_report_list = ReportList()
        self.__qt_report_list.setObjectName("detial_report_list")
        self.__qt_fix_selected_button = QtWidgets.QPushButton("Fix Selected")
        self.__qt_fix_all_button = QtWidgets.QPushButton("Fix All")
        self.__qt_fix_selected_button.setObjectName("detail_button")
        self.__qt_fix_all_button.setObjectName("detail_button")
        self.__qt_fix_selected_button.setMaximumWidth(100)
        self.__qt_fix_all_button.setMaximumWidth(100)

        button_layout.addWidget(self.__qt_fix_selected_button)
        button_layout.addWidget(self.__qt_fix_all_button)

        frame_layout.addWidget(self.__qt_tester_label)
        frame_layout.addSpacing(20)
        frame_layout.addWidget(self.__qt_description)
        frame_layout.addWidget(self.__qt_report_list)
        frame_layout.addLayout(self.__qt_parameter_layout)
        frame_layout.addLayout(button_layout)

        self.__qt_fix_all_button.clicked.connect(self.__fixAll)
        self.__qt_fix_selected_button.clicked.connect(self.__fixSelected) 
开发者ID:sol-ansano-kim,项目名称:medic,代码行数:47,代码来源:widgets.py

示例13: buildUI

# 需要导入模块: from Qt import QtWidgets [as 别名]
# 或者: from Qt.QtWidgets import QPushButton [as 别名]
def buildUI(self):
        # Like in the LightWidget we show our
        layout = QtWidgets.QGridLayout(self)

        # We create a combobox
        # Comboboxes are essentially dropdown selectionwidgets
        self.lightTypeCB = QtWidgets.QComboBox()
        # We populate it with the items in our lightTypes dictionary
        # I like to have my items alphabetically so I sort it to begin with
        for lightType in sorted(self.lightTypes):
            # We add the option to the combobox
            self.lightTypeCB.addItem(lightType)
        # Finally we add it to the layout in row 0, column 0
        # We tell it take 1 row and two columns worth of space
        layout.addWidget(self.lightTypeCB, 0, 0, 1, 2)

        # We create a button to create the chosen lights
        createBtn = QtWidgets.QPushButton('Create')
        # We connect the button so it calls the createLight method when its clicked
        createBtn.clicked.connect(self.createLight)
        # We add it to the layout in row 0, column 2
        layout.addWidget(createBtn, 0, 2)

        # We want to put all the LightWidgets inside a scrolling container
        # We first need a container widget
        scrollWidget = QtWidgets.QWidget()
        # We want to make sure this widget only tries to be the maximum size of its contents
        scrollWidget.setSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Maximum)
        # Then we give it a vertical layout because we want everything arranged vertically
        self.scrollLayout = QtWidgets.QVBoxLayout(scrollWidget)

        # Finally we create a scrollArea that will be in charge of scrolling its contents
        scrollArea = QtWidgets.QScrollArea()
        # Make sure it's resizable so it resizes as the UI grows or shrinks
        scrollArea.setWidgetResizable(True)
        # Then we set it to use our container widget to scroll
        scrollArea.setWidget(scrollWidget)
        # Then we add this scrollArea to the main layout, at row 1, column 0
        # We tell it to take 1 row and 3 columns of space
        layout.addWidget(scrollArea, 1, 0, 1, 3)

        # We add the save button to save our lights
        saveBtn = QtWidgets.QPushButton('Save')
        # When clicked it will call the saveLights method
        saveBtn.clicked.connect(self.saveLights)
        # We add it to row 2, column 0
        layout.addWidget(saveBtn, 2, 0)

        # We also add an import button to import our lights
        importBtn = QtWidgets.QPushButton('Import')
        # When clicked it will call the importLights method
        importBtn.clicked.connect(self.importLights)
        # We add it to row 2, column 1
        layout.addWidget(importBtn, 2, 1)

        # We need a refresh button to manually force the UI to refresh on changes
        refreshBtn = QtWidgets.QPushButton('Refresh')
        # We'll connect this to the refresh method
        refreshBtn.clicked.connect(self.refresh)
        # Finally we add it to the layout at row 2, column 2
        layout.addWidget(refreshBtn, 2, 2) 
开发者ID:dgovil,项目名称:PythonForMayaSamples,代码行数:63,代码来源:lightManager2016Below.py


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