本文整理汇总了Python中qtpy.QtWidgets.QCheckBox.setText方法的典型用法代码示例。如果您正苦于以下问题:Python QCheckBox.setText方法的具体用法?Python QCheckBox.setText怎么用?Python QCheckBox.setText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtWidgets.QCheckBox
的用法示例。
在下文中一共展示了QCheckBox.setText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dialog
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import setText [as 别名]
def dialog(title, text, icon, setting=None, default=None):
if not getattr(settings, setting.upper()):
return True
check = QCheckBox()
check.setText('Dont show this message again (can be reset via the preferences)')
info = QMessageBox()
info.setIcon(icon)
info.setText(title)
info.setInformativeText(text)
info.setCheckBox(check)
info.setStandardButtons(info.Cancel | info.Ok)
if default == 'Cancel':
info.setDefaultButton(info.Cancel)
result = info.exec_()
if result == info.Cancel:
return False
if check.isChecked():
setattr(settings, setting.upper(), False)
save_settings()
return True
示例2: MessageCheckBox
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import setText [as 别名]
class MessageCheckBox(QMessageBox):
"""
A QMessageBox derived widget that includes a QCheckBox aligned to the right
under the message and on top of the buttons.
"""
def __init__(self, *args, **kwargs):
super(MessageCheckBox, self).__init__(*args, **kwargs)
self._checkbox = QCheckBox()
# Set layout to include checkbox
size = 9
check_layout = QVBoxLayout()
check_layout.addItem(QSpacerItem(size, size))
check_layout.addWidget(self._checkbox, 0, Qt.AlignRight)
check_layout.addItem(QSpacerItem(size, size))
# Access the Layout of the MessageBox to add the Checkbox
layout = self.layout()
if PYQT5:
layout.addLayout(check_layout, 1, 2)
else:
layout.addLayout(check_layout, 1, 1)
# --- Public API
# Methods to access the checkbox
def is_checked(self):
return self._checkbox.isChecked()
def set_checked(self, value):
return self._checkbox.setChecked(value)
def set_check_visible(self, value):
self._checkbox.setVisible(value)
def is_check_visible(self):
self._checkbox.isVisible()
def checkbox_text(self):
self._checkbox.text()
def set_checkbox_text(self, text):
self._checkbox.setText(text)
示例3: set_check_box
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import setText [as 别名]
def set_check_box(self, row, col, state):
""" function to add a new select checkbox to a cell in a table row
won't add a new checkbox if one already exists
"""
# Check input
assert isinstance(state, bool)
# Check if cellWidget exists
if self.cellWidget(row, col):
# existing: just set the value
self.cellWidget(row, col).setChecked(state)
else:
# case to add checkbox
checkbox = QCheckBox()
checkbox.setText('')
checkbox.setChecked(state)
# Adding a widget which will be inserted into the table cell
# then centering the checkbox within this widget which in turn,
# centers it within the table column :-)
self.setCellWidget(row, col, checkbox)
# END-IF-ELSE
return
示例4: SpyderErrorDialog
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import setText [as 别名]
class SpyderErrorDialog(QDialog):
"""Custom error dialog for error reporting."""
def __init__(self, parent=None):
QDialog.__init__(self, parent)
self.setWindowTitle(_("Spyder internal error"))
self.setModal(True)
# To save the traceback sent to the internal console
self.error_traceback = ""
# Dialog main label
self.main_label = QLabel(
_("""<b>Spyder has encountered an internal problem</b><hr>
Please enter below a step-by-step description of
your problem (in English). Issue reports without
a clear way to reproduce them will be closed.
<br><br>
<b>Note</b>: You need a Github account for this.
"""))
self.main_label.setWordWrap(True)
self.main_label.setAlignment(Qt.AlignJustify)
# Field to input the description of the problem
self.input_description = DescriptionWidget(self)
# Only allow to submit to Github if we have a long enough description
self.input_description.textChanged.connect(self._description_changed)
# Widget to show errors
self.details = ShowErrorWidget(self)
self.details.set_pythonshell_font(get_font())
self.details.hide()
# Label to show missing chars
self.initial_chars = len(self.input_description.toPlainText())
self.chars_label = QLabel(_("Enter at least {} "
"characters".format(MIN_CHARS)))
# Checkbox to dismiss future errors
self.dismiss_box = QCheckBox()
self.dismiss_box.setText(_("Don't show again during this session"))
# Labels layout
labels_layout = QHBoxLayout()
labels_layout.addWidget(self.chars_label)
labels_layout.addWidget(self.dismiss_box, 0, Qt.AlignRight)
# Dialog buttons
self.submit_btn = QPushButton(_('Submit to Github'))
self.submit_btn.setEnabled(False)
self.submit_btn.clicked.connect(self._submit_to_github)
self.details_btn = QPushButton(_('Show details'))
self.details_btn.clicked.connect(self._show_details)
self.close_btn = QPushButton(_('Close'))
# Buttons layout
buttons_layout = QHBoxLayout()
buttons_layout.addWidget(self.submit_btn)
buttons_layout.addWidget(self.details_btn)
buttons_layout.addWidget(self.close_btn)
# Main layout
vlayout = QVBoxLayout()
vlayout.addWidget(self.main_label)
vlayout.addWidget(self.input_description)
vlayout.addWidget(self.details)
vlayout.addLayout(labels_layout)
vlayout.addLayout(buttons_layout)
self.setLayout(vlayout)
self.resize(600, 420)
self.input_description.setFocus()
def _submit_to_github(self):
"""Action to take when pressing the submit button."""
main = self.parent().main
# Getting description and traceback
description = self.input_description.toPlainText()
traceback = self.error_traceback[:-1] # Remove last eol
# Render issue
issue_text = main.render_issue(description=description,
traceback=traceback)
# Copy issue to clipboard
QApplication.clipboard().setText(issue_text)
# Submit issue to Github
issue_body=("<!--- "
"Please paste the contents of your clipboard "
"below to complete reporting your problem. "
"--->\n\n")
main.report_issue(body=issue_body,
title="Automatic error report")
def append_traceback(self, text):
#.........这里部分代码省略.........
示例5: KernelConnectionDialog
# 需要导入模块: from qtpy.QtWidgets import QCheckBox [as 别名]
# 或者: from qtpy.QtWidgets.QCheckBox import setText [as 别名]
#.........这里部分代码省略.........
# SSH authentication layout
auth_layout = QGridLayout()
auth_layout.addWidget(self.pw_radio, 1, 0)
auth_layout.addWidget(pw_label, 1, 1)
auth_layout.addWidget(self.pw, 1, 2)
auth_layout.addWidget(self.kf_radio, 2, 0)
auth_layout.addWidget(kf_label, 2, 1)
auth_layout.addLayout(kf_layout, 2, 2)
auth_layout.addWidget(kfp_label, 3, 1)
auth_layout.addWidget(self.kfp, 3, 2)
auth_group.setLayout(auth_layout)
# Remote kernel layout
rm_layout = QVBoxLayout()
rm_layout.addLayout(ssh_layout)
rm_layout.addSpacerItem(QSpacerItem(QSpacerItem(0, 8)))
rm_layout.addWidget(auth_group)
self.rm_group.setLayout(rm_layout)
self.rm_group.setCheckable(True)
self.rm_group.toggled.connect(self.pw_radio.setChecked)
# Ok and Cancel buttons
self.accept_btns = QDialogButtonBox(
QDialogButtonBox.Ok | QDialogButtonBox.Cancel,
Qt.Horizontal, self)
self.accept_btns.accepted.connect(self.save_connection_settings)
self.accept_btns.accepted.connect(self.accept)
self.accept_btns.rejected.connect(self.reject)
# Save connection settings checkbox
self.save_layout = QCheckBox(self)
self.save_layout.setText(_("Save connection settings"))
btns_layout = QHBoxLayout()
btns_layout.addWidget(self.save_layout)
btns_layout.addWidget(self.accept_btns)
# Dialog layout
layout = QVBoxLayout(self)
layout.addWidget(main_label)
layout.addSpacerItem(QSpacerItem(QSpacerItem(0, 8)))
layout.addLayout(cf_layout)
layout.addSpacerItem(QSpacerItem(QSpacerItem(0, 12)))
layout.addWidget(self.rm_group)
layout.addLayout(btns_layout)
self.load_connection_settings()
def load_connection_settings(self):
"""Load the user's previously-saved kernel connection settings."""
existing_kernel = CONF.get("existing-kernel", "settings", {})
connection_file_path = existing_kernel.get("json_file_path", "")
is_remote = existing_kernel.get("is_remote", False)
username = existing_kernel.get("username", "")
hostname = existing_kernel.get("hostname", "")
port = str(existing_kernel.get("port", 22))
is_ssh_kf = existing_kernel.get("is_ssh_keyfile", False)
ssh_kf = existing_kernel.get("ssh_key_file_path", "")
if connection_file_path != "":
self.cf.setText(connection_file_path)
if username != "":
self.un.setText(username)