本文整理匯總了Python中PyQt5.QtWidgets.QDialogButtonBox.Cancel方法的典型用法代碼示例。如果您正苦於以下問題:Python QDialogButtonBox.Cancel方法的具體用法?Python QDialogButtonBox.Cancel怎麽用?Python QDialogButtonBox.Cancel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.QtWidgets.QDialogButtonBox
的用法示例。
在下文中一共展示了QDialogButtonBox.Cancel方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: on_button_4_clicked
# 需要導入模塊: from PyQt5.QtWidgets import QDialogButtonBox [as 別名]
# 或者: from PyQt5.QtWidgets.QDialogButtonBox import Cancel [as 別名]
def on_button_4_clicked(self):
log.debug("clicked: B4: {}".format(self.winId()))
dialog_b4 = QDialog(flags=(Qt.Dialog | Qt.FramelessWindowHint))
ui = Ui_DialogConfirmOff()
ui.setupUi(dialog_b4)
dialog_b4.move(0, 0)
ui.buttonBox.button(QDialogButtonBox.Yes).setText("Shutdown")
ui.buttonBox.button(QDialogButtonBox.Retry).setText("Restart")
ui.buttonBox.button(QDialogButtonBox.Cancel).setText("Cancel")
ui.buttonBox.button(QDialogButtonBox.Yes).clicked.connect(self.b4_shutdown)
ui.buttonBox.button(QDialogButtonBox.Retry).clicked.connect(self.b4_restart)
dialog_b4.show()
rsp = dialog_b4.exec_()
if rsp == QDialog.Accepted:
log.info("B4: pressed is: Accepted - Shutdown or Restart")
else:
log.info("B4: pressed is: Cancel")
示例2: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QDialogButtonBox [as 別名]
# 或者: from PyQt5.QtWidgets.QDialogButtonBox import Cancel [as 別名]
def __init__(self, parent=None, rename_existing_id=None):
super().__init__(parent)
self.setupUi(self)
self.edited_profile = None
self.buttonBox.rejected.connect(self.close)
self.buttonBox.accepted.connect(self.save)
self.profileNameField.textChanged.connect(self.button_validation)
self.buttonBox.button(QDialogButtonBox.Save).setText(self.tr("Save"))
self.buttonBox.button(QDialogButtonBox.Cancel).setText(self.tr("Cancel"))
if rename_existing_id is not None:
existing_profile = BackupProfileModel.get(id=rename_existing_id)
self.profileNameField.setText(existing_profile.name)
self.existing_id = rename_existing_id
self.modalTitle.setText(self.tr('Rename Profile'))
# Call validate to set inital messages
self.buttonBox.button(QDialogButtonBox.Save).setEnabled(self.validate())
示例3: remove_user_list
# 需要導入模塊: from PyQt5.QtWidgets import QDialogButtonBox [as 別名]
# 或者: from PyQt5.QtWidgets.QDialogButtonBox import Cancel [as 別名]
def remove_user_list(self):
text = 'Are you sure you want to remove this list? Information for every user in the list will be lost'
reply = message.warning(self, 'Remove User List?', text, message.Ok, message.Cancel)
return reply == message.Ok
示例4: remove_subreddit_list
# 需要導入模塊: from PyQt5.QtWidgets import QDialogButtonBox [as 別名]
# 或者: from PyQt5.QtWidgets.QDialogButtonBox import Cancel [as 別名]
def remove_subreddit_list(self):
text = 'Are you sure you want to remove this list? Information for every subreddit in the list will be lost'
reply = message.warning(self, 'Remove Subreddit List?', text, message.Ok, message.Cancel)
return reply == message.Ok
示例5: downloader_running_warning
# 需要導入模塊: from PyQt5.QtWidgets import QDialogButtonBox [as 別名]
# 或者: from PyQt5.QtWidgets.QDialogButtonBox import Cancel [as 別名]
def downloader_running_warning(self):
text = 'The user finder is still currently running. Closing now may cause unexpected behaviour and corrupted '\
'files. Are you sure you want to close?'
reply = message.warning(self, 'User Finder Still Running', text, message.Ok, message.Cancel)
return reply == message.Ok
示例6: restore_defaults_warning
# 需要導入模塊: from PyQt5.QtWidgets import QDialogButtonBox [as 別名]
# 或者: from PyQt5.QtWidgets.QDialogButtonBox import Cancel [as 別名]
def restore_defaults_warning(self):
text = 'Defaults have been restored. If you save now, any settings controlled from this window will be ' \
'restored to their original values.\n\nAny user or subreddit who\'s custom settings have been changed ' \
'will also be restored to their default values.\n\nDo you wish to proceed?'
reply = message.warning(self, 'Defaults Restored', text, message.Ok, message.Cancel)
return reply == message.Ok
示例7: update_reddit_objects_message
# 需要導入模塊: from PyQt5.QtWidgets import QDialogButtonBox [as 別名]
# 或者: from PyQt5.QtWidgets.QDialogButtonBox import Cancel [as 別名]
def update_reddit_objects_message(self):
text = "Saved reddit objects are from a previous version of the program and are no\n" \
"longer compatible. These objects will now be updated to the latest version\n" \
"and the application will be saved. All of the objects settings and download list\n" \
"will be carried over to new objects.\n" \
"If you do not update these objects, the saved objects will not work correctly\n" \
"and will most likely cause the application to crash"
reply = message.information(self, "Update Reddit Objects", text, message.Ok, message.Cancel)
return reply == message.Ok
示例8: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QDialogButtonBox [as 別名]
# 或者: from PyQt5.QtWidgets.QDialogButtonBox import Cancel [as 別名]
def __init__(self):
"""
A small class to display an unfinished dialog message to the user. It is made into its own class so the names
of the buttons can be renamed to be better understood in the situation it is used in
"""
QDialog.__init__(self)
self.setupUi(self)
self.button_box.button(QDialogButtonBox.Ok).setText('Close Anyway')
self.button_box.button(QDialogButtonBox.Cancel).setText('Do Not Close')
self.button_box.accepted.connect(self.accept)
self.button_box.rejected.connect(self.close)
示例9: initUI
# 需要導入模塊: from PyQt5.QtWidgets import QDialogButtonBox [as 別名]
# 或者: from PyQt5.QtWidgets.QDialogButtonBox import Cancel [as 別名]
def initUI(self):
self.setWindowTitle("請稍等……")
self.setWindowIcon(QIcon(SRC_DIR + "password.ico"))
self.lb_oldpwd = QLabel()
self.lb_oldpwd.setText("當前提取碼:")
self.lb_oldpwd.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter)
self.tx_oldpwd = QLineEdit()
# 當前提取碼 隻讀
self.tx_oldpwd.setFocusPolicy(Qt.NoFocus)
self.tx_oldpwd.setReadOnly(True)
self.lb_newpwd = QLabel()
self.lb_newpwd.setText("新的提取碼:")
self.lb_newpwd.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter)
self.tx_newpwd = QLineEdit()
self.buttonBox = QDialogButtonBox()
self.buttonBox.setOrientation(Qt.Horizontal)
self.buttonBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.buttonBox.button(QDialogButtonBox.Ok).setText("確定")
self.buttonBox.button(QDialogButtonBox.Cancel).setText("取消")
self.grid = QGridLayout()
self.grid.setSpacing(10)
self.grid.addWidget(self.lb_oldpwd, 1, 0)
self.grid.addWidget(self.tx_oldpwd, 1, 1)
self.grid.addWidget(self.lb_newpwd, 2, 0)
self.grid.addWidget(self.tx_newpwd, 2, 1)
self.grid.addWidget(self.buttonBox, 3, 0, 1, 2)
self.setLayout(self.grid)
self.buttonBox.accepted.connect(self.btn_ok)
self.buttonBox.accepted.connect(self.accept)
self.buttonBox.accepted.connect(self.set_tip)
self.buttonBox.rejected.connect(self.reject)
self.buttonBox.rejected.connect(self.set_tip)
self.setMinimumWidth(280)
示例10: initUI
# 需要導入模塊: from PyQt5.QtWidgets import QDialogButtonBox [as 別名]
# 或者: from PyQt5.QtWidgets.QDialogButtonBox import Cancel [as 別名]
def initUI(self):
self.setWindowTitle("確認刪除")
self.setWindowIcon(QIcon(SRC_DIR + "delete.ico"))
self.layout = QVBoxLayout()
self.list_view = QListView()
self.list_view.setViewMode(QListView.ListMode)
# 列表
self.slm = QStandardItem()
self.model = QStandardItemModel()
max_len = 10
count = 0
for info in self.infos:
if info.is_file: # 文件
self.model.appendRow(QStandardItem(set_file_icon(info.name), info.name))
else:
self.model.appendRow(QStandardItem(QIcon(SRC_DIR + "folder.gif"), info.name))
self.out.append({'fid': info.id, 'is_file': info.is_file, 'name': info.name}) # id,文件標示, 文件名
count += 1
if max_len < len(info.name): # 使用最大文件名長度
max_len = len(info.name)
self.list_view.setModel(self.model)
self.lb_name = QLabel("嘗試刪除以下{}個文件(夾):".format(count))
self.buttonBox = QDialogButtonBox()
self.buttonBox.setOrientation(Qt.Horizontal)
self.buttonBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.buttonBox.button(QDialogButtonBox.Ok).setText("確定")
self.buttonBox.button(QDialogButtonBox.Cancel).setText("取消")
self.layout.addWidget(self.lb_name)
self.layout.addWidget(self.list_view)
self.layout.addWidget(self.buttonBox)
self.setLayout(self.layout)
self.buttonBox.accepted.connect(self.btn_ok)
self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject)
self.setMinimumWidth(400)
self.resize(int(max_len*8), int(count*34+60))
示例11: initUI
# 需要導入模塊: from PyQt5.QtWidgets import QDialogButtonBox [as 別名]
# 或者: from PyQt5.QtWidgets.QDialogButtonBox import Cancel [as 別名]
def initUI(self):
self.setWindowIcon(QIcon(SRC_DIR + "desc.ico"))
self.lb_name = QLabel()
self.lb_name.setText("文件夾名:")
self.lb_name.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter)
self.tx_name = QLineEdit()
self.lb_desc = QLabel()
self.tx_desc = QTextEdit()
self.lb_desc.setText("描 述:")
self.lb_desc.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter)
self.buttonBox = QDialogButtonBox()
self.buttonBox.setOrientation(Qt.Horizontal)
self.buttonBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.buttonBox.button(QDialogButtonBox.Ok).setText("確定")
self.buttonBox.button(QDialogButtonBox.Cancel).setText("取消")
self.grid = QGridLayout()
self.grid.setSpacing(10)
self.grid.addWidget(self.lb_name, 1, 0)
self.grid.addWidget(self.tx_name, 1, 1)
self.grid.addWidget(self.lb_desc, 2, 0)
self.grid.addWidget(self.tx_desc, 2, 1, 5, 1)
self.grid.addWidget(self.buttonBox, 7, 1, 1, 1)
self.setLayout(self.grid)
self.buttonBox.accepted.connect(self.btn_ok)
self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject)
示例12: initUI
# 需要導入模塊: from PyQt5.QtWidgets import QDialogButtonBox [as 別名]
# 或者: from PyQt5.QtWidgets.QDialogButtonBox import Cancel [as 別名]
def initUI(self):
self.setWindowTitle("移動文件(夾)")
self.setWindowIcon(QIcon(SRC_DIR + "move.ico"))
self.lb_name = QLabel()
self.lb_name.setText("文件(夾)名:")
self.lb_name.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter)
self.tx_name = AutoResizingTextEdit()
self.tx_name.setFocusPolicy(Qt.NoFocus) # 隻讀
self.tx_name.setReadOnly(True)
self.lb_new_path = QLabel()
self.lb_new_path.setText("目標文件夾:")
self.lb_new_path.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter)
self.tx_new_path = QComboBox()
self.buttonBox = QDialogButtonBox()
self.buttonBox.setOrientation(Qt.Horizontal)
self.buttonBox.setStandardButtons(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.buttonBox.button(QDialogButtonBox.Ok).setText("確定")
self.buttonBox.button(QDialogButtonBox.Cancel).setText("取消")
self.grid = QGridLayout()
self.grid.setSpacing(10)
self.grid.addWidget(self.lb_name, 1, 0)
self.grid.addWidget(self.tx_name, 1, 1)
self.grid.addWidget(self.lb_new_path, 2, 0)
self.grid.addWidget(self.tx_new_path, 2, 1)
self.grid.addWidget(self.buttonBox, 3, 0, 1, 2)
self.setLayout(self.grid)
self.buttonBox.accepted.connect(self.btn_ok)
self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject)
self.setMinimumWidth(280)
示例13: initUI
# 需要導入模塊: from PyQt5.QtWidgets import QDialogButtonBox [as 別名]
# 或者: from PyQt5.QtWidgets.QDialogButtonBox import Cancel [as 別名]
def initUI(self):
self.setWindowTitle('搜索設置')
self.setWindowIcon(QIcon('logo.jpg'))
self.resize(280, 200)
self.l1 = QLabel(self.info, self)
self.l1.setGeometry(30, 40, 100, 30)
self.l1.setAlignment(Qt.AlignCenter)
self.e1 = QLineEdit(self)
self.e1.setGeometry(130, 40, 100, 25)
self.l2 = QLabel('隻抓取原創微博', self)
self.l2.setGeometry(30, 100, 100, 30)
self.l2.setAlignment(Qt.AlignCenter)
# 創建複選框1,並默認選中,當狀態改變時信號觸發事件
# self.checkBox1 = QCheckBox("&Checkbox1",self)
self.checkBox1 = QCheckBox(self)
self.checkBox1.setGeometry(170, 100, 80, 30)
self.checkBox1.setChecked(True)
self.checkBox1.stateChanged.connect(self.btnClicked)
# 確定取消按鈕
self.buttonBox = QDialogButtonBox(self)
self.buttonBox.setGeometry(120,160,100,30)
self.buttonBox.setOrientation(Qt.Horizontal)
self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel |QDialogButtonBox.Ok)
self.buttonBox.accepted.connect(self.accept)
self.buttonBox.rejected.connect(self.reject)
示例14: __init__
# 需要導入模塊: from PyQt5.QtWidgets import QDialogButtonBox [as 別名]
# 或者: from PyQt5.QtWidgets.QDialogButtonBox import Cancel [as 別名]
def __init__(self, parent=None):
super(LoginDialog, self).__init__(parent)
# etykiety, pola edycyjne i przyciski ###
loginLbl = QLabel('Login')
hasloLbl = QLabel('Hasło')
self.login = QLineEdit()
self.haslo = QLineEdit()
self.przyciski = QDialogButtonBox(
QDialogButtonBox.Ok | QDialogButtonBox.Cancel,
Qt.Horizontal, self)
# układ główny ###
uklad = QGridLayout(self)
uklad.addWidget(loginLbl, 0, 0)
uklad.addWidget(self.login, 0, 1)
uklad.addWidget(hasloLbl, 1, 0)
uklad.addWidget(self.haslo, 1, 1)
uklad.addWidget(self.przyciski, 2, 0, 2, 0)
# sygnały i sloty ###
self.przyciski.accepted.connect(self.accept)
self.przyciski.rejected.connect(self.reject)
# właściwości widżetu ###
self.setModal(True)
self.setWindowTitle('Logowanie')
示例15: textChanged
# 需要導入模塊: from PyQt5.QtWidgets import QDialogButtonBox [as 別名]
# 或者: from PyQt5.QtWidgets.QDialogButtonBox import Cancel [as 別名]
def textChanged(self,_):
login = self.textName.text()
passwd = self.textPass.text()
if len(passwd) >= config.min_passwd_len and len(login) >= config.min_login_len and "@" in login and "." in login:
self.dialogbuttons.button(QDialogButtonBox.Cancel).setDefault(False)
self.dialogbuttons.button(QDialogButtonBox.Ok).setEnabled(True)
self.dialogbuttons.button(QDialogButtonBox.Ok).setDefault(True)
else:
self.dialogbuttons.button(QDialogButtonBox.Cancel).setDefault(True)
self.dialogbuttons.button(QDialogButtonBox.Ok).setDefault(False)
self.dialogbuttons.button(QDialogButtonBox.Ok).setEnabled(False)