本文整理匯總了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()