本文整理汇总了Python中PyQt5.QtWidgets.QMessageBox.Cancel方法的典型用法代码示例。如果您正苦于以下问题:Python QMessageBox.Cancel方法的具体用法?Python QMessageBox.Cancel怎么用?Python QMessageBox.Cancel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QMessageBox
的用法示例。
在下文中一共展示了QMessageBox.Cancel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_attributes
# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Cancel [as 别名]
def test_attributes(qtbot):
"""Test basic QMessageBox attributes."""
title = 'title'
text = 'text'
parent = QWidget()
qtbot.add_widget(parent)
icon = QMessageBox.Critical
buttons = QMessageBox.Ok | QMessageBox.Cancel
box = msgbox.msgbox(parent=parent, title=title, text=text, icon=icon,
buttons=buttons)
qtbot.add_widget(box)
if not utils.is_mac:
assert box.windowTitle() == title
assert box.icon() == icon
assert box.standardButtons() == buttons
assert box.text() == text
assert box.parent() is parent
示例2: on_btnCancelEditingMn_clicked
# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Cancel [as 别名]
def on_btnCancelEditingMn_clicked(self, checked):
if self.app_config.is_modified():
if WndUtils.queryDlg('Configuration modified. Discard changes?',
buttons=QMessageBox.Yes | QMessageBox.Cancel,
default_button=QMessageBox.Cancel, icon=QMessageBox.Warning) == QMessageBox.Yes:
# reload the configuration (we don't keep the old values)
sel_mn_idx = self.app_config.masternodes.index(self.cur_masternode)
# reload the configuration from file
self.load_configuration_from_file(self.app_config.app_config_file_name, ask_save_changes=False)
self.editing_enabled = False
if sel_mn_idx >= 0 and sel_mn_idx < len(self.app_config.masternodes):
self.cur_masternode = self.app_config.masternodes[sel_mn_idx]
self.display_masternode_config(sel_mn_idx)
self.wdg_masternode.set_edit_mode(self.editing_enabled)
self.update_edit_controls_state()
else:
if self.cur_masternode and self.cur_masternode.new:
idx = self.app_config.masternodes.index(self.cur_masternode)
if idx >= 0:
self.app_config.masternodes.remove(self.cur_masternode)
self.cboMasternodes.removeItem(self.cboMasternodes.currentIndex())
self.editing_enabled = False
self.wdg_masternode.set_edit_mode(self.editing_enabled)
self.update_edit_controls_state()
self.update_mn_controls_state()
示例3: on_btnEnDisPass_clicked
# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Cancel [as 别名]
def on_btnEnDisPass_clicked(self):
try:
if self.hw_session and self.hw_session.hw_client:
if self.passphrase_protection is True:
# disable passphrase
if self.queryDlg('Do you really want to disable passphrase protection of your %s?' % self.main_ui.getHwName(),
buttons=QMessageBox.Yes | QMessageBox.Cancel, default_button=QMessageBox.Cancel,
icon=QMessageBox.Warning) == QMessageBox.Yes:
hw_intf.enable_passphrase(self.hw_session, passphrase_enabled=False)
self.read_hw_features()
self.updateControlsState()
elif self.passphrase_protection is False:
# enable passphrase
if self.queryDlg('Do you really want to enable passphrase protection of your %s?' % self.main_ui.getHwName(),
buttons=QMessageBox.Yes | QMessageBox.Cancel, default_button=QMessageBox.Cancel,
icon=QMessageBox.Warning) == QMessageBox.Yes:
hw_intf.enable_passphrase(self.hw_session, passphrase_enabled=True)
self.read_hw_features()
self.updateControlsState()
except Exception as e:
self.errorMsg(str(e))
示例4: make_further_instructions
# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Cancel [as 别名]
def make_further_instructions(self, pr):
def further_instructions():
response = QMessageBox.information(self, "Next Step", "To continue, send the necessary amounts of Bitcoin to the addresses specified in the 'Outputs' field above. Once broadcast, press Yes to Continue or Cancel to quit.", QMessageBox.Cancel | QMessageBox.Yes, QMessageBox.Cancel)
if response == QMessageBox.Cancel:
sys.exit()
elif response == QMessageBox.Yes:
if pr.details.payment_url:
raw_tx, okPressed1 = QInputDialog.getText(self, "Enter Raw Transaction","Enter the hex of the transaction that was just made:", QLineEdit.Normal, "")
if okPressed1 and raw_tx != '':
ref_addr, okPressed2 = QInputDialog.getText(self, "Enter Refund Address","Enter a refund address:", QLineEdit.Normal, "")
if okPressed2 and ref_addr != '':
try:
result = pr.send_ack(raw_tx.strip(), ref_addr.strip())
if result[0]:
QMessageBox.information(self, "Complete!", "Payment request successful: " + result[1] + "\n\nClick Ok to exit", QMessageBox.Ok, QMessageBox.Ok)
sys.exit()
else:
QMessageBox.error(self, "Error!", "Payment request was not successful: " + result[1] + "\n\nClick Ok to exit", QMessageBox.Ok, QMessageBox.Ok)
sys.exit()
except:
QMessageBox.error(self, "Error!", "There was an error parsing the raw transaction or address. Please restart and try again.\n\nClick Ok to exit", QMessageBox.Ok, QMessageBox.Ok)
sys.exit()
return further_instructions
示例5: promptToSave
# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Cancel [as 别名]
def promptToSave(self):
if cm.ConfigManager.SETTINGS[cm.PROMPT_TO_SAVE]:
# TODO: i18n
result = QMessageBox.question(
self.window(),
"Save changes?",
"There are unsaved changes. Would you like to save them?",
QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel
)
if result == QMessageBox.Yes:
return self.on_save()
elif result == QMessageBox.Cancel:
return True
else:
return False
else:
# don't prompt, just save
return self.on_save()
# ---- Signal handlers
示例6: unsavedCheck
# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Cancel [as 别名]
def unsavedCheck(self):
if self.savedVersion != self.currentVersion:
msg = QMessageBox()
msg.setText("The current file has unsaved changes. Close without saving?")
msg.setWindowTitle("Close without saving?")
msg.setStandardButtons(QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel)
res = msg.exec_()
if res == QMessageBox.Save:
self.save()
return True
if res == QMessageBox.Discard:
return True
return False
return True
# Outputs the filename component of the title
示例7: test_quit_modified_cancelled_from_button
# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Cancel [as 别名]
def test_quit_modified_cancelled_from_button():
"""
If the user quits and there's unsaved work, and they cancel the "quit" then
do nothing.
"""
view = mock.MagicMock()
view.modified = True
view.show_confirmation = mock.MagicMock(return_value=QMessageBox.Cancel)
ed = mu.logic.Editor(view)
mock_open = mock.MagicMock()
mock_open.return_value.__enter__ = lambda s: s
mock_open.return_value.__exit__ = mock.Mock()
mock_open.return_value.write = mock.MagicMock()
with mock.patch("sys.exit", return_value=None), mock.patch(
"builtins.open", mock_open
):
ed.quit()
assert view.show_confirmation.call_count == 1
assert mock_open.call_count == 0
示例8: test_quit_modified_cancelled_from_event
# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Cancel [as 别名]
def test_quit_modified_cancelled_from_event():
"""
If the user quits and there's unsaved work, and they cancel the "quit" then
do nothing.
"""
view = mock.MagicMock()
view.modified = True
view.show_confirmation = mock.MagicMock(return_value=QMessageBox.Cancel)
ed = mu.logic.Editor(view)
mock_open = mock.MagicMock()
mock_open.return_value.__enter__ = lambda s: s
mock_open.return_value.__exit__ = mock.Mock()
mock_open.return_value.write = mock.MagicMock()
mock_event = mock.MagicMock()
mock_event.ignore = mock.MagicMock(return_value=None)
with mock.patch("sys.exit", return_value=None), mock.patch(
"builtins.open", mock_open
):
ed.quit(mock_event)
assert view.show_confirmation.call_count == 1
assert mock_event.ignore.call_count == 1
assert mock_open.call_count == 0
示例9: test_check_usb_change_mode_cancel
# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Cancel [as 别名]
def test_check_usb_change_mode_cancel():
"""
Ensure the check_usb doesn't change mode if confirmation cancelled by user.
"""
view = mock.MagicMock()
view.show_confirmation = mock.MagicMock(return_value=QMessageBox.Cancel)
ed = mu.logic.Editor(view)
ed.change_mode = mock.MagicMock()
mode_py = mock.MagicMock()
mode_py.name = "Python3"
mode_py.runner = None
mode_py.find_device.return_value = (None, None)
mode_cp = mock.MagicMock()
mode_cp.name = "CircuitPlayground"
mode_cp.find_device.return_value = ("/dev/ttyUSB1", "12345")
ed.modes = {"circuitplayground": mode_cp, "python": mode_py}
ed.show_status_message = mock.MagicMock()
ed.check_usb()
expected = "Detected new CircuitPlayground device."
ed.show_status_message.assert_called_with(expected)
assert view.show_confirmation.called
ed.change_mode.assert_not_called()
示例10: test_check_usb_when_selecting_mode_is_silent
# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Cancel [as 别名]
def test_check_usb_when_selecting_mode_is_silent():
"""
Ensure the check_usb doesn't ask to change mode if the user has the mode
selection dialog active (indicated by the selecting_mode flag.
"""
view = mock.MagicMock()
view.show_confirmation = mock.MagicMock(return_value=QMessageBox.Cancel)
ed = mu.logic.Editor(view)
ed.change_mode = mock.MagicMock()
mode_py = mock.MagicMock()
mode_py.name = "Python3"
mode_py.runner = None
mode_py.find_device.return_value = (None, None)
mode_cp = mock.MagicMock()
mode_cp.name = "CircuitPlayground"
mode_cp.find_device.return_value = ("/dev/ttyUSB1", "12345")
ed.modes = {"circuitplayground": mode_cp, "python": mode_py}
ed.show_status_message = mock.MagicMock()
ed.selecting_mode = True
ed.check_usb()
expected = "Detected new CircuitPlayground device."
ed.show_status_message.assert_called_with(expected)
assert view.show_confirmation.call_count == 0
ed.change_mode.assert_not_called()
示例11: generate_priv_key
# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Cancel [as 别名]
def generate_priv_key(self, pk_type:str, edit_control: QLineEdit, compressed: bool):
if edit_control.text():
if WndUtils.queryDlg(
f'This will overwrite the current {pk_type} private key value. Do you really want to proceed?',
buttons=QMessageBox.Yes | QMessageBox.Cancel,
default_button=QMessageBox.Yes, icon=QMessageBox.Warning) != QMessageBox.Yes:
return None
if pk_type == 'operator':
pk = dash_utils.generate_bls_privkey()
else:
pk = dash_utils.generate_wif_privkey(self.app_config.dash_network, compressed=compressed)
edit_control.setText(pk)
return pk
示例12: load_configuration_from_file
# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Cancel [as 别名]
def load_configuration_from_file(self, file_name: str, ask_save_changes = True,
update_current_file_name = True) -> None:
"""
Load configuration from a file.
:param file_name: A name of the configuration file to be loaded into the application.
"""
if self.app_config.is_modified() and ask_save_changes:
ret = self.queryDlg('Current configuration has been modified. Save?',
buttons=QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel,
default_button=QMessageBox.Yes, icon=QMessageBox.Warning)
if ret == QMessageBox.Yes:
self.save_configuration()
elif ret == QMessageBox.Cancel:
self.update_config_files_mru_menu_items()
return
try:
self.disconnect_hardware_wallet()
dash_network_sav = self.app_config.dash_network
self.app_config.read_from_file(hw_session=self.hw_session, file_name=file_name,
update_current_file_name=update_current_file_name)
self.editing_enabled = False
self.configuration_to_ui()
self.dashd_intf.reload_configuration()
self.app_config.modified = False
file_name = self.app_config.app_config_file_name
if file_name:
self.add_item_to_config_files_mru_list(file_name)
self.update_config_files_mru_menu_items()
if dash_network_sav != self.app_config.dash_network:
self.disconnect_hardware_wallet()
self.app_config.reset_network_dependent_dyn_params()
self.display_window_title()
except CancelException:
self.update_config_files_mru_menu_items()
示例13: on_action_clear_wallet_cache_triggered
# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Cancel [as 别名]
def on_action_clear_wallet_cache_triggered(self, checked):
if self.queryDlg('Do you really want to clear the wallet cache?',
buttons=QMessageBox.Yes | QMessageBox.Cancel,
default_button=QMessageBox.Cancel, icon=QMessageBox.Warning) == QMessageBox.Yes:
db_cursor = self.app_config.db_intf.get_cursor()
try:
db_cursor.execute('drop table address')
db_cursor.execute('drop table hd_tree')
db_cursor.execute('drop table tx_input')
db_cursor.execute('drop table tx_output')
db_cursor.execute('drop table tx')
self.app_config.db_intf.create_structures()
finally:
self.app_config.db_intf.release_cursor()
self.infoMsg('Wallet cache cleared.')
示例14: on_action_clear_proposals_cache_triggered
# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Cancel [as 别名]
def on_action_clear_proposals_cache_triggered(self, checked):
if self.queryDlg('Do you really want to clear the proposals cache?',
buttons=QMessageBox.Yes | QMessageBox.Cancel,
default_button=QMessageBox.Cancel, icon=QMessageBox.Warning) == QMessageBox.Yes:
db_cursor = self.app_config.db_intf.get_cursor()
try:
db_cursor.execute('drop table proposals')
db_cursor.execute('drop table voting_results')
self.app_config.db_intf.create_structures()
finally:
self.app_config.db_intf.release_cursor()
self.infoMsg('Proposals cache cleared.')
示例15: try_close_model
# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Cancel [as 别名]
def try_close_model(self):
if self._model_mgr.modified:
reply = QMessageBox.question(
self.modeler,
"OPC UA Modeler",
"Model is modified, do you really want to close model?",
QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel
)
if reply != QMessageBox.Yes:
return False
self._model_mgr.close_model(force=True)
return True