本文整理汇总了Python中PyQt5.QtWidgets.QMessageBox.Question方法的典型用法代码示例。如果您正苦于以下问题:Python QMessageBox.Question方法的具体用法?Python QMessageBox.Question怎么用?Python QMessageBox.Question使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QMessageBox
的用法示例。
在下文中一共展示了QMessageBox.Question方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: msg_box
# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Question [as 别名]
def msg_box(text, title=None, icon=None, parent=None, buttons=QMessageBox.Yes | QMessageBox.No, default=QMessageBox.No,
type=QMessageBox.Question):
res = get_themed_box(parent)
if title is not None:
res.setWindowTitle(title)
if icon is not None:
res.setWindowIcon(icon)
res.setIcon(type)
res.setStandardButtons(buttons)
res.setDefaultButton(default)
res.setText(text)
res.adjustSize()
if parent:
center_widget(res, parent)
return res
示例2: my_close
# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Question [as 别名]
def my_close(self):
not_show = settings.read('not_show_close_dialog', False, type=bool)
if not not_show:
cb = QCheckBox("Do not show this again.")
msgbox = QMessageBox(QMessageBox.Question, "Confirm close", "Are you sure you want to close?")
msgbox.addButton(QMessageBox.Yes)
msgbox.addButton(QMessageBox.No)
msgbox.setDefaultButton(QMessageBox.No)
msgbox.setCheckBox(cb)
reply = msgbox.exec()
not_show_again = bool(cb.isChecked())
settings.write("not_show_close_dialog", not_show_again)
self.not_show_again_changed.emit()
if reply != QMessageBox.Yes:
return
self.closed.emit(self)
示例3: train
# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Question [as 别名]
def train(self):
try:
if not os.path.isdir(self.datasets):
raise FileNotFoundError
text = '系统将开始训练人脸数据,界面会暂停响应一段时间,完成后会弹出提示。'
informativeText = '<b>训练过程请勿进行其它操作,是否继续?</b>'
ret = DataManageUI.callDialog(QMessageBox.Question, text, informativeText,
QMessageBox.Yes | QMessageBox.No,
QMessageBox.No)
if ret == QMessageBox.Yes:
face_recognizer = cv2.face.LBPHFaceRecognizer_create()
if not os.path.exists('./recognizer'):
os.makedirs('./recognizer')
faces, labels = self.prepareTrainingData(self.datasets)
face_recognizer.train(faces, np.array(labels))
face_recognizer.save('./recognizer/trainingData.yml')
except FileNotFoundError:
logging.error('系统找不到人脸数据目录{}'.format(self.datasets))
self.trainButton.setIcon(QIcon('./icons/error.png'))
self.logQueue.put('未发现人脸数据目录{},你可能未进行人脸采集'.format(self.datasets))
except Exception as e:
logging.error('遍历人脸库出现异常,训练人脸数据失败')
self.trainButton.setIcon(QIcon('./icons/error.png'))
self.logQueue.put('Error:遍历人脸库出现异常,训练失败')
else:
text = '<font color=green><b>Success!</b></font> 系统已生成./recognizer/trainingData.yml'
informativeText = '<b>人脸数据训练完成!</b>'
DataManageUI.callDialog(QMessageBox.Information, text, informativeText, QMessageBox.Ok)
self.trainButton.setIcon(QIcon('./icons/success.png'))
self.logQueue.put('Success:人脸数据训练完成')
self.initDb()
# 系统日志服务常驻,接收并处理系统日志
示例4: save_all
# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Question [as 别名]
def save_all(self):
if self.num_frames == 0:
return
try:
not_show = settings.read('not_show_save_dialog', False, type=bool)
except TypeError:
not_show = False
if not not_show:
cb = QCheckBox("Don't ask me again.")
msg_box = QMessageBox(QMessageBox.Question, self.tr("Confirm saving all signals"),
self.tr("All changed signal files will be overwritten. OK?"))
msg_box.addButton(QMessageBox.Yes)
msg_box.addButton(QMessageBox.No)
msg_box.setCheckBox(cb)
reply = msg_box.exec()
not_show_again = cb.isChecked()
settings.write("not_show_save_dialog", not_show_again)
self.not_show_again_changed.emit()
if reply != QMessageBox.Yes:
return
for f in self.signal_frames:
if f.signal is None or f.signal.filename == "":
continue
f.signal.save()
示例5: myPopUp
# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Question [as 别名]
def myPopUp(parentWindow, messType, messTitle, messText, defaultButton=QMessageBox.No):
if messType in QT_MESSAGE_TYPE:
type = QT_MESSAGE_TYPE[messType]
else:
type = QMessageBox.Question
mess = QMessageBox(type, messTitle, messText, defaultButton, parent=parentWindow)
mess.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
mess.setDefaultButton(defaultButton)
return mess.exec_()
示例6: onSendRewards
# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Question [as 别名]
def onSendRewards(self):
self.dest_addr = self.ui.destinationLine.text().strip()
self.currFee = self.ui.feeLine.value() * 1e8
# Check spending collateral
if (not self.ui.collateralHidden and
self.ui.rewardsList.box.collateralRow is not None and
self.ui.rewardsList.box.item(self.ui.rewardsList.box.collateralRow, 0).isSelected() ):
warning1 = "Are you sure you want to transfer the collateral?"
warning2 = "Really?"
warning3 = "Take a deep breath. Do you REALLY want to transfer your collateral?"
ans = myPopUp(self.caller, "warn", 'SPMT - warning', warning1)
if ans == QMessageBox.No:
return None
else:
ans2 = myPopUp(self.caller, "warn", 'SPMT - warning', warning2)
if ans2 == QMessageBox.No:
return None
else:
ans2 = myPopUp(self.caller, "crit", 'SPMT - warning', warning3)
if ans2 == QMessageBox.No:
return None
# Check HW device
while self.caller.hwStatus != 2:
mess = "HW device not connected. Try to connect?"
ans = myPopUp(self.caller, QMessageBox.Question, 'SPMT - hw check', mess)
if ans == QMessageBox.No:
return
# re connect
self.caller.onCheckHw()
# SEND
self.SendRewards(self.useSwiftX())
示例7: onStartMN
# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Question [as 别名]
def onStartMN(self, data=None):
# Check RPC & HW device
if not self.caller.rpcConnected or self.caller.hwStatus != 2:
myPopUp_sb(self.caller, "crit", 'SPMT - hw/rpc device check', "Connect to RPC server and HW device first")
printDbg("Hardware device or RPC server not connected")
return None
try:
if not data:
target = self.ui.sender()
masternode_alias = target.alias
printOK("Start-masternode %s pressed" % masternode_alias)
for mn_conf in self.caller.masternode_list:
if mn_conf['name'] == masternode_alias:
reply = myPopUp(self.caller, QMessageBox.Question, 'Confirm START',
"Are you sure you want to start masternoode:\n'%s'?" % mn_conf['name'], QMessageBox.Yes)
if reply == QMessageBox.Yes:
self.masternodeToStart = Masternode(self, mn_conf['name'], mn_conf['ip'], mn_conf['port'],
mn_conf['mnPrivKey'], mn_conf['hwAcc'], mn_conf['collateral'], mn_conf['isTestnet'])
# connect signal
self.masternodeToStart.sigdone.connect(self.sendBroadcast)
self.mnToStartList.append(self.masternodeToStart)
self.startMN()
break
except Exception as e:
err_msg = "error before starting node"
printException(getCallerName(), getFunctionName(), err_msg, e)
示例8: startFaceRecord
# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Question [as 别名]
def startFaceRecord(self, startFaceRecordButton):
if startFaceRecordButton.text() == '开始采集人脸数据':
if self.isFaceDetectEnabled:
if self.isUserInfoReady:
self.addOrUpdateUserInfoButton.setEnabled(False)
if not self.enableFaceRecordButton.isEnabled():
self.enableFaceRecordButton.setEnabled(True)
self.enableFaceRecordButton.setIcon(QIcon())
self.startFaceRecordButton.setIcon(QIcon('./icons/success.png'))
self.startFaceRecordButton.setText('结束当前人脸采集')
else:
self.startFaceRecordButton.setIcon(QIcon('./icons/error.png'))
self.startFaceRecordButton.setChecked(False)
self.logQueue.put('Error:操作失败,系统未检测到有效的用户信息')
else:
self.startFaceRecordButton.setIcon(QIcon('./icons/error.png'))
self.logQueue.put('Error:操作失败,请开启人脸检测')
else:
if self.faceRecordCount < self.minFaceRecordCount:
text = '系统当前采集了 <font color=blue>{}</font> 帧图像,采集数据过少会导致较大的识别误差。'.format(self.faceRecordCount)
informativeText = '<b>请至少采集 <font color=red>{}</font> 帧图像。</b>'.format(self.minFaceRecordCount)
DataRecordUI.callDialog(QMessageBox.Information, text, informativeText, QMessageBox.Ok)
else:
text = '系统当前采集了 <font color=blue>{}</font> 帧图像,继续采集可以提高识别准确率。'.format(self.faceRecordCount)
informativeText = '<b>你确定结束当前人脸采集吗?</b>'
ret = DataRecordUI.callDialog(QMessageBox.Question, text, informativeText,
QMessageBox.Yes | QMessageBox.No,
QMessageBox.No)
if ret == QMessageBox.Yes:
self.isFaceDataReady = True
if self.isFaceRecordEnabled:
self.isFaceRecordEnabled = False
self.enableFaceRecordButton.setEnabled(False)
self.enableFaceRecordButton.setIcon(QIcon())
self.startFaceRecordButton.setText('开始采集人脸数据')
self.startFaceRecordButton.setEnabled(False)
self.startFaceRecordButton.setIcon(QIcon())
self.migrateToDbButton.setEnabled(True)
# 定时器,实时更新画面
示例9: on_new_topfolder
# 需要导入模块: from PyQt5.QtWidgets import QMessageBox [as 别名]
# 或者: from PyQt5.QtWidgets.QMessageBox import Question [as 别名]
def on_new_topfolder(self):
logger.info("User initiates top-level folder creation")
message_box = QMessageBox(
QMessageBox.Question,
"Create Folder",
"Create folder in the default location?",
QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel,
self.window()
)
message_box.button(QMessageBox.No).setText("Create elsewhere") # TODO: i18n
result = message_box.exec_()
self.window().app.monitor.suspend()
if result == QMessageBox.Yes:
logger.debug("User creates a new top-level folder.")
self.__createFolder(None)
elif result == QMessageBox.No:
logger.debug("User creates a new folder and chose to create it elsewhere")
QMessageBox.warning(
self.window(), "Beware",
"AutoKey will take the full ownership of the directory you are about to select or create. "
"It is advisable to only choose empty directories or directories that contain data created by AutoKey "
"previously.\n\nIf you delete or move the directory from within AutoKey "
"(for example by using drag and drop), all files unknown to AutoKey will be deleted.",
QMessageBox.Ok)
path = QFileDialog.getExistingDirectory(
self.window(),
"Where should the folder be created?"
)
if path != "":
path = pathlib.Path(path)
if list(path.glob("*")):
result = QMessageBox.warning(
self.window(), "The chosen directory already contains files",
"The selected directory already contains files. "
"If you continue, AutoKey will take the ownership.\n\n"
"You may lose all files in '{}' that are not related to AutoKey if you select this directory.\n"
"Continue?".format(path),
QMessageBox.Yes|QMessageBox.No) == QMessageBox.Yes
else:
result = True
if result:
folder = model.Folder(path.name, path=str(path))
new_item = ak_tree.FolderWidgetItem(None, folder)
self.treeWidget.addTopLevelItem(new_item)
self.configManager.folders.append(folder)
self.window().app.config_altered(True)
self.window().app.monitor.unsuspend()
else:
logger.debug("User canceled top-level folder creation.")
self.window().app.monitor.unsuspend()