def closeEvent(self, event):
reply = QMessageBox.question(self, 'Message',
"Are you sure to quit?", QMessageBox.Yes |
QMessageBox.No, QMessageBox.No)
if reply == QMessageBox.Yes:
event.accept()
else:
event.ignore()
python类Yes()的实例源码
def user_not_valid(self, user):
text = '%s is not a valid user. Would you like to remove this user from the user list?' % user
reply = message.information(self, 'Invalid User', text, message.Yes, message.No)
return reply == message.Ok
def subreddit_not_valid(self, sub):
text = '%s is not a valid subreddit. Would you like to remove this sub from the subreddit list?' % sub
reply = message.information(self, 'Invalid Subreddit', text, message.Yes, message.No)
return reply == message.Ok
def unsaved_close_message(self):
text = "Save changes to Downloader For Reddit?"
reply = message.question(self, "Save Changes?", text, message.Yes | message.No | message.Cancel, message.Cancel)
if reply == message.Yes:
return "SAVE"
elif reply == message.No:
return "CLOSE"
else:
return "CANCEL"
def sigint_handler(*args):
"""Handler for the SIGINT signal."""
sys.stderr.write('\r')
if QMessageBox.question(None, '', "Are you sure you want to quit?",
QMessageBox.Yes | QMessageBox.No,
QMessageBox.No) == QMessageBox.Yes:
QApplication.quit()
def sigint_handler(*args):
"""Handler for the SIGINT signal."""
sys.stderr.write('\r')
if QMessageBox.question(None, '', "Are you sure you want to quit?",
QMessageBox.Yes | QMessageBox.No,
QMessageBox.No) == QMessageBox.Yes:
QApplication.quit()
NetworkPrinterOutputDevice.py 文件源码
项目:UM3NetworkPrintingPlugin
作者: Ultimaker
项目源码
文件源码
阅读 14
收藏 0
点赞 0
评论 0
def _configurationMismatchMessageCallback(self, button):
def delayedCallback():
if button == QMessageBox.Yes:
self.startPrint()
else:
Application.getInstance().showPrintMonitor.emit(False)
# For some unknown reason Cura on OSX will hang if we do the call back code
# immediately without first returning and leaving QML's event system.
QTimer.singleShot(100, delayedCallback)
NetworkPrinterOutputDevice.py 文件源码
项目:UM3NetworkPrintingPlugin
作者: Ultimaker
项目源码
文件源码
阅读 18
收藏 0
点赞 0
评论 0
def materialHotendChangedMessage(self, callback):
Application.getInstance().messageBox(i18n_catalog.i18nc("@window:title", "Changes on the Printer"),
i18n_catalog.i18nc("@label",
"Would you like to update your current printer configuration into Cura?"),
i18n_catalog.i18nc("@label",
"The PrintCores and/or materials on your printer were changed. For the best result, always slice for the PrintCores and materials that are inserted in your printer."),
buttons=QMessageBox.Yes + QMessageBox.No,
icon=QMessageBox.Question,
callback=callback
)
def save_all(self):
if self.num_frames == 0:
return
settings = constants.SETTINGS
try:
not_show = settings.value('not_show_save_dialog', type=bool, defaultValue=False)
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.setValue("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()
def slot_startDownload(self):
url = self.urlL_ineEdit.text()
path = self.save_path_lineEdit.text()
type = self.comboBox.currentIndex()
try:
if url is None or url.strip() == "":
QMessageBox.information(self, "??", "????????", QMessageBox.Yes)
elif not re.match('http:\/\/.*?\/', url):
QMessageBox.information(self, "??", "????????", QMessageBox.Yes)
elif path is None or path.strip() == "":
QMessageBox.information(self, "??", "??????????", QMessageBox.Yes)
else:
html = GetMezi._get_html(url)
soup = GetMezi._get_soup(html)
if self.TYPE_MORE == type:
albums = GetMezi._get_img_dirs(soup)
if None == albums:
QMessageBox.information(self, "??", "???????????????????????????????????????????", QMessageBox.Yes)
else:
QMessageBox.information(self, "??", "?????...", QMessageBox.Yes)
self.downloadButton.setDisabled(True)
self.bwThread = AlbumsThread(path, albums)
self.bwThread.finishSignal.connect(self.resetDownloadBtn)
self.bwThread.start()
elif self.TYPE_SINGLE == type:
title = GetMezi._get_page_title(soup)
QMessageBox.information(self, "??", "?????...", QMessageBox.Yes)
self.downloadButton.setDisabled(True)
self.bwThread = SingleAlbumThread(path, title, url)
self.bwThread.finishSignal.connect(self.resetDownloadBtn)
self.bwThread.start()
except Exception as e:
print(e)
QMessageBox.information(self, "??", "???‘????’?‘????’?????\n ??????????????\n ???http://www.mzitu.com/ \n ? http://www.mzitu.com/xinggan \n ????????????????\n http://www.mzitu.com/75636 ", QMessageBox.Yes)
def resetDownloadBtn(self):
self.downloadButton.setDisabled(False)
QMessageBox.information(self, "??", "????", QMessageBox.Yes)
def __init_storage(self):
"""
Initialize the connection with the SQLite database.
:raise DatabaseError: if the database schema is not consistent.
"""
is_new_database = not os.path.isfile(B3_STORAGE)
self.storage = sqlite3.connect(B3_STORAGE, check_same_thread=False)
self.storage.isolation_level = None # set autocommit mode
self.storage.row_factory = sqlite3.Row # allow row index by name
if is_new_database:
# create new schema
self.__build_schema()
else:
# check database schema
LOG.debug('checking database schema')
cursor = self.storage.cursor()
cursor.execute("""SELECT * FROM sqlite_master WHERE type='table'""")
tables = [row[1] for row in cursor.fetchall()]
cursor.close()
if 'b3' not in tables:
LOG.debug('database schema is corrupted: asking the user if he wants to rebuild it')
msgbox = QMessageBox()
msgbox.setIcon(QMessageBox.Critical)
msgbox.setText('The database schema is corrupted and must be rebuilt. Do you want to proceed?')
msgbox.setInformativeText('NOTE: all the previously saved data will be lost!')
msgbox.setStandardButtons(QMessageBox.No | QMessageBox.Yes)
msgbox.setDefaultButton(QMessageBox.No)
msgbox.exec_()
if msgbox.result() == QMessageBox.No:
# critical will raise an exception which will terminate the QApplication
LOG.critical('could not start B3: database schema is corrupted!')
try:
os.remove(B3_STORAGE)
self.__build_schema()
except Exception, err:
raise LOG.critical('could initialize SQLite database: %s (%s): make sure B3 has permissions to '
'operate on this file, or remove it manually', B3_STORAGE, err)
def _warn_existing_output_dir(self, path):
path = os.path.abspath(path)
reply = QMessageBox.question(self, "Reuse previous data",
"Intermediate files were found at\n{0}\nDo you want to reuse them?".format(path),
QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
reuse = int(reply) == QMessageBox.Yes
if not reuse:
shutil.rmtree(path)
def confirm_on_empty(self, name):
if not self._has_data:
reply = QMessageBox.question(self, "Confirm Save Plot",
"{0} plot is empty\nAre you sure you want to save it?".format(name),
QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
return int(reply) == QMessageBox.Yes
return True
def run_auto_login(self):
STATUS.RUN = True
pl.run_thread([(auto_login, ())], name='auto_run', is_lock=False)
QMessageBox.information(self, '??', '??????', QMessageBox.Yes)
def stop_auto_login(self):
STATUS.RUN = False
pl.kill_thread(name='auto_run')
QMessageBox.information(self, '??', '??????', QMessageBox.Yes)
def show_update_result(self):
title = '????'
msg = '????? ??%s?????' % self.num
QMessageBox.information(self, title, msg, QMessageBox.Yes)
def closeEvent(self, event):
'''
Closing endPlate window.
'''
ui_input = self.getuser_inputs()
self.save_inputs(ui_input)
reply = QMessageBox.question(self, 'Message',
"Are you sure to quit?", QMessageBox.Yes, QMessageBox.No)
if reply == QMessageBox.Yes:
self.closed.emit()
event.accept()
else:
event.ignore()
# ********************************* Help Action *********************************************************************************************
def deleteFile(self, menu):
# show Warning message to the user.
# check persepolis_setting first!
# perhaps user checked "do not show this message again"
delete_warning_message = self.persepolis_setting.value(
'MainWindow/delete-warning', 'yes')
if delete_warning_message == 'yes':
self.msgBox = QMessageBox()
self.msgBox.setText("<b><center>This operation will delete \
downloaded files from your hard disk<br>PERMANENTLY!</center></b>")
self.msgBox.setInformativeText("<center>Do you want to continue?</center>")
self.msgBox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
self.msgBox.setIcon(QMessageBox.Warning)
dont_show_checkBox = QtWidgets.QCheckBox("don't show this message again")
self.msgBox.setCheckBox(dont_show_checkBox)
reply = self.msgBox.exec_()
# if user checks "do not show this message again!", change persepolis_setting!
if self.msgBox.checkBox().isChecked():
self.persepolis_setting.setValue(
'MainWindow/delete-warning', 'no')
# do nothing if user clicks NO
if reply != QMessageBox.Yes:
return
# if checking_flag is equal to 1, it means that user pressed remove or
# delete button or ... . so checking download information must be
# stopped until job is done!
if checking_flag != 2:
wait_check = WaitThread()
self.threadPool.append(wait_check)
self.threadPool[len(self.threadPool) - 1].start()
self.threadPool[len(self.threadPool) -
1].QTABLEREADY.connect(self.deleteFile2)
else:
self.deleteFile2()
def deleteSelected(self, menu):
# showing Warning message to the user.
# checking persepolis_setting first!
# perhaps user was checking "do not show this message again"
delete_warning_message = self.persepolis_setting.value(
'MainWindow/delete-warning', 'yes')
if delete_warning_message == 'yes':
self.msgBox = QMessageBox()
self.msgBox.setText("<b><center>This operation will delete \
downloaded files from your hard disk<br>PERMANENTLY!</center></b>")
self.msgBox.setInformativeText("<center>Do you want to continue?</center>")
self.msgBox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
self.msgBox.setIcon(QMessageBox.Warning)
dont_show_checkBox = QtWidgets.QCheckBox("don't show this message again")
self.msgBox.setCheckBox(dont_show_checkBox)
reply = self.msgBox.exec_()
# if user checks "do not show this message again!", change persepolis_setting!
if self.msgBox.checkBox().isChecked():
self.persepolis_setting.setValue(
'MainWindow/delete-warning', 'no')
# do nothing if user clicks NO
if reply != QMessageBox.Yes:
return
# if checking_flag is equal to 1, it means that user pressed remove or
# delete button or ... . so checking download information must be
# stopped until job is done!
if checking_flag != 2:
wait_check = WaitThread()
self.threadPool.append(wait_check)
self.threadPool[len(self.threadPool) - 1].start()
self.threadPool[len(self.threadPool) -
1].QTABLEREADY.connect(self.deleteSelected2)
else:
self.deleteSelected2()