本文整理汇总了Python中PyQt5.QtWidgets.QPushButton方法的典型用法代码示例。如果您正苦于以下问题:Python QtWidgets.QPushButton方法的具体用法?Python QtWidgets.QPushButton怎么用?Python QtWidgets.QPushButton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets
的用法示例。
在下文中一共展示了QtWidgets.QPushButton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QPushButton [as 别名]
def __init__(self, setting_params=None):
super().__init__()
self.setting_params = setting_params
self.search_input = Qw.QLineEdit()
self.table = AngryTableView(self.setting_params['angrysearch_lite'],
self.setting_params['row_height'])
self.upd_button = Qw.QPushButton('update')
self.fts_checkbox = Qw.QCheckBox()
grid = Qw.QGridLayout()
grid.setSpacing(10)
grid.addWidget(self.search_input, 1, 1)
grid.addWidget(self.fts_checkbox, 1, 3)
grid.addWidget(self.upd_button, 1, 4)
grid.addWidget(self.table, 2, 1, 4, 4)
self.setLayout(grid)
self.setTabOrder(self.search_input, self.table)
self.setTabOrder(self.table, self.upd_button)
# THE MAIN APPLICATION WINDOW WITH THE STATUS BAR AND LOGIC
# LOADS AND SAVES QSETTINGS FROM ~/.config/angrysearch
# INITIALIZES AND SETS GUI, WAITING FOR USER INPUTS
示例2: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QPushButton [as 别名]
def __init__(self, parent=None, win=None, element="", info=()):
super(RenameDialog, self).__init__(parent)
self.sourceWin = parent
self.info = info
self.element = element
title = "Rename: " + element
self.setWindowTitle(title)
layout = QtWidgets.QGridLayout()
question = QtWidgets.QLabel("Please enter new name:")
layout.addWidget(question, 0, 0)
self.lineEdit = QtWidgets.QLineEdit()
layout.addWidget(self.lineEdit, 0, 1)
self.buttonOK = QtWidgets.QPushButton("OK", self)
layout.addWidget(self.buttonOK, 1, 1)
self.buttonCancel = QtWidgets.QPushButton("Cancel", self)
layout.addWidget(self.buttonCancel, 1, 0)
self.lineEdit.setText(self.element)
self.setLayout(layout)
self.buttonCancel.clicked.connect(self.cancelClicked)
self.buttonOK.clicked.connect(self.okClicked)
示例3: initUI
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QPushButton [as 别名]
def initUI(self):
self.inputLabel = QLabel("Input your text")
self.editLine = QLineEdit()
self.printButton = QPushButton("Print")
self.clearButton = QPushButton("Clear")
self.printButton.clicked.connect(self.printText)
self.clearButton.clicked.connect(self.clearText)
inputLayout = QHBoxLayout()
inputLayout.addWidget(self.inputLabel)
inputLayout.addWidget(self.editLine)
buttonLayout = QHBoxLayout()
buttonLayout.addWidget(self.printButton)
buttonLayout.addWidget(self.clearButton)
mainLayout = QVBoxLayout()
mainLayout.addLayout(inputLayout)
mainLayout.addLayout(buttonLayout)
self.setLayout(mainLayout)
self.setWindowTitle('FristWindow')
self.show()
示例4: buttonToggled
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QPushButton [as 别名]
def buttonToggled(self, button):
"""
:type button: QPushButton
:param button:
:return:
"""
if button == self.rectButton:
self.trigger.emit(ACTION_RECT)
elif button == self.ellipseButton:
self.trigger.emit(ACTION_ELLIPSE)
elif button == self.arrowButton:
self.trigger.emit(ACTION_ARROW)
elif button == self.lineButton:
self.trigger.emit(ACTION_LINE)
elif button == self.freePenButton:
self.trigger.emit(ACTION_FREEPEN)
elif button == self.textButton:
self.trigger.emit(ACTION_TEXT)
else:
pass
示例5: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QPushButton [as 别名]
def __init__(self, parent=None):
super(TextInput, self).__init__(parent)
self.setWindowFlags(Qt.Dialog | Qt.FramelessWindowHint)
self.mainLayout = QVBoxLayout()
self.textArea = QTextEdit(self)
self.buttonArea = QWidget(self)
self.buttonLayout = QHBoxLayout()
self.cancelButton = QPushButton('Cancel', self)
self.okButton = QPushButton('Ok', self)
self.buttonLayout.addWidget(self.cancelButton)
self.buttonLayout.addWidget(self.okButton)
self.buttonArea.setLayout(self.buttonLayout)
self.mainLayout.addWidget(self.textArea)
self.mainLayout.addWidget(self.buttonArea)
self.setLayout(self.mainLayout)
self.textArea.textChanged.connect(self.textChanged_)
self.okButton.clicked.connect(self.okButtonClicked)
self.cancelButton.clicked.connect(self.cancelPressed)
示例6: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QPushButton [as 别名]
def __init__(self, parent=None, button_func=None, params=None):
super().__init__(parent, 'Introduction', params)
self.button_func = button_func
path = os.path.abspath(os.path.dirname(__file__)) + '/static/'
path += 'introduction'
text = self.get_text(path)
self.set_paragraph('MALSS interactive', text=text)
btn = QPushButton('Next', self.inner)
btn.setStyleSheet('QPushButton{font: bold; font-size: 15pt; background-color: white;};')
if self.params.lang == 'en':
btn.clicked.connect(lambda: self.button_func('Task'))
else:
btn.clicked.connect(lambda: self.button_func('分析タスク'))
self.vbox.addStretch(1)
self.vbox.addWidget(btn)
示例7: equationsLayout
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QPushButton [as 别名]
def equationsLayout(self):
self.myQListWidget = QtWidgets.QListWidget(self)
for index, name in self.equations:
myQCustomQWidget = QCustomQWidget()
myQCustomQWidget.setTextUp(index)
myQCustomQWidget.setTextDown(name)
myQListWidgetItem = QtWidgets.QListWidgetItem(self.myQListWidget)
myQListWidgetItem.setSizeHint(myQCustomQWidget.sizeHint())
self.myQListWidget.addItem(myQListWidgetItem)
self.myQListWidget.setItemWidget(
myQListWidgetItem, myQCustomQWidget)
self.myQListWidget.resize(400, 300)
self.equationListVbox.addWidget(self.myQListWidget)
self.myQListWidget.itemClicked.connect(self.Clicked)
self.clearButton = QtWidgets.QPushButton('Clear equations')
self.clearButton.clicked.connect(self.clearHistory)
self.clearButton.setStatusTip("Clear history")
self.equationListVbox.addWidget(self.clearButton)
return self.equationListVbox
示例8: buttonsLayout
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QPushButton [as 别名]
def buttonsLayout(self):
self.matrix = False
vbox = QVBoxLayout()
interactionModeLayout = QVBoxLayout()
self.interactionModeButton = QtWidgets.QPushButton('visma')
self.interactionModeButton.clicked.connect(self.interactionMode)
interactionModeLayout.addWidget(self.interactionModeButton)
interactionModeWidget = QWidget(self)
interactionModeWidget.setLayout(interactionModeLayout)
interactionModeWidget.setFixedSize(275, 50)
topButtonSplitter = QSplitter(Qt.Horizontal)
topButtonSplitter.addWidget(interactionModeWidget)
permanentButtons = QWidget(self)
topButtonSplitter.addWidget(permanentButtons)
self.bottomButton = QFrame()
self.buttonSplitter = QSplitter(Qt.Vertical)
self.buttonSplitter.addWidget(topButtonSplitter)
self.buttonSplitter.addWidget(self.bottomButton)
vbox.addWidget(self.buttonSplitter)
return vbox
示例9: wrtVariableButtons
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QPushButton [as 别名]
def wrtVariableButtons(self, variables, operation):
if isinstance(variables, list):
varButtons = []
if len(variables) > 0:
for variable in variables:
varButtons.append(variable)
varButtons.append("back")
for i in reversed(range(self.solutionOptionsBox.count())):
self.solutionOptionsBox.itemAt(i).widget().setParent(None)
for i in range(int(len(varButtons) / 2) + 1):
for j in range(2):
if len(varButtons) > (i * 2 + j):
self.solutionButtons[(i, j)] = QtWidgets.QPushButton(
varButtons[i * 2 + j])
self.solutionButtons[(i, j)].resize(100, 100)
self.solutionButtons[(i, j)].clicked.connect(
self.onWRTVariablePress(varButtons[i * 2 + j], operation))
self.solutionOptionsBox.addWidget(
self.solutionButtons[(i, j)], i, j)
示例10: onActivated
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QPushButton [as 别名]
def onActivated(self, text):
for i in reversed(range(self.inputBox.count())):
self.inputBox.itemAt(i).widget().setParent(None)
for i in range(4):
for j in range(10):
if str(text) in "Greek":
if (i * 10 + j) < len(self.inputGreek):
self.buttons[(i, j)] = QtWidgets.QPushButton(
self.inputGreek[i * 10 + j])
self.buttons[(i, j)].resize(100, 100)
self.buttons[(i, j)].clicked.connect(
self.onInputPress(self.inputGreek[i * 10 + j]))
self.inputBox.addWidget(self.buttons[(i, j)], i, j)
elif str(text) in "LaTeX":
if (i * 10 + j) < len(self.inputLaTeX):
self.buttons[(i, j)] = QtWidgets.QPushButton(
self.inputLaTeX[i * 10 + j])
self.buttons[(i, j)].resize(100, 100)
self.buttons[(i, j)].clicked.connect(
self.onInputPress(self.inputLaTeX[i * 10 + j]))
self.inputBox.addWidget(self.buttons[(i, j)], i, j)
self.selectedCombo = str(text)
示例11: view_configuration_info
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QPushButton [as 别名]
def view_configuration_info(self):
self.thread_stop = True
container = QtWidgets.QVBoxLayout()
label = QtWidgets.QLabel('Configuration Information')
label.setStyleSheet('font: 18px;')
container.addWidget(label)
layout = QtWidgets.QHBoxLayout()
self.message = QtWidgets.QLabel()
layout.addWidget(self.message)
layout.addStretch()
save_button = QtWidgets.QPushButton('Save')
layout.addWidget(save_button)
scroll_layout = FIRSTUI.ScrollWidget(frame=QtWidgets.QFrame.NoFrame)
FIRSTUI.SharedObjects.server_config_layout(self, scroll_layout, FIRST.config)
container.addWidget(scroll_layout)
container.addStretch()
container.addLayout(layout)
save_button.clicked.connect(self.save_config)
return container
示例12: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QPushButton [as 别名]
def __init__(self, parent=None):
super().__init__(parent)
prompt = 'user@chatimus ~$'
self.button = QtWidgets.QPushButton(prompt)
self.button.setStyleSheet("""color: white; font: bold;
font-size: 18px;""")
# TODO: intergrate into stylesheet
# NOTE: setting `outline: None` did not work
self.button.setFlat(True)
self.line_edit = LineEdit()
layout = QtWidgets.QHBoxLayout()
layout.addWidget(self.button)
layout.addWidget(self.line_edit)
layout.setSpacing(0)
self.setLayout(layout)
self.listener_signal = self.line_edit.listener_signal
self.button.clicked.connect(self.give_focus)
示例13: init_ui
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QPushButton [as 别名]
def init_ui(self):
"""Setup control widget UI."""
self.control_layout = QHBoxLayout()
self.setLayout(self.control_layout)
self.reset_button = QPushButton()
self.reset_button.setFixedSize(40, 40)
self.reset_button.setIcon(QtGui.QIcon(WIN_PATH))
self.game_timer = QLCDNumber()
self.game_timer.setStyleSheet("QLCDNumber {color: red;}")
self.game_timer.setFixedWidth(100)
self.move_counter = QLCDNumber()
self.move_counter.setStyleSheet("QLCDNumber {color: red;}")
self.move_counter.setFixedWidth(100)
self.control_layout.addWidget(self.game_timer)
self.control_layout.addWidget(self.reset_button)
self.control_layout.addWidget(self.move_counter)
示例14: __init__
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QPushButton [as 别名]
def __init__(self, etree, control, parent=None):
QtWidgets.QPushButton.__init__(self)
self.setLayout(QtWidgets.QHBoxLayout())
self.layout().setContentsMargins(0,0,0,0)
self.layout().setSpacing(0)
pkmixins.LayoutMixin._init(self, etree, control, parent)
示例15: setupUi
# 需要导入模块: from PyQt5 import QtWidgets [as 别名]
# 或者: from PyQt5.QtWidgets import QPushButton [as 别名]
def setupUi(self, About):
About.setObjectName("About")
About.resize(498, 369)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(About.sizePolicy().hasHeightForWidth())
About.setSizePolicy(sizePolicy)
self.verticalLayout = QtWidgets.QVBoxLayout(About)
self.verticalLayout.setObjectName("verticalLayout")
self.gridLayout_11 = QtWidgets.QGridLayout()
self.gridLayout_11.setObjectName("gridLayout_11")
self.label_6 = QtWidgets.QLabel(About)
self.label_6.setObjectName("label_6")
self.gridLayout_11.addWidget(self.label_6, 1, 1, 1, 1)
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.gridLayout_11.addItem(spacerItem, 1, 2, 1, 1)
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.gridLayout_11.addItem(spacerItem1, 1, 0, 1, 1)
spacerItem2 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
self.gridLayout_11.addItem(spacerItem2, 0, 1, 1, 1)
spacerItem3 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.gridLayout_11.addItem(spacerItem3, 2, 1, 1, 1)
self.verticalLayout.addLayout(self.gridLayout_11)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
spacerItem4 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem4)
self.button_close = QtWidgets.QPushButton(About)
self.button_close.setObjectName("button_close")
self.horizontalLayout.addWidget(self.button_close)
self.verticalLayout.addLayout(self.horizontalLayout)
self.retranslateUi(About)
QtCore.QMetaObject.connectSlotsByName(About)