def mainbutton_clicked(self, button): if button == self.main_reset: for cat in self.base_cfg.get_categories(): for setting in self.base_cfg.get_settings(cat): self.widget_list[cat][setting].updateValue(self.base_cfg.get_setting(cat,setting)) elif button == self.main_defaults: for cat in self.def_cfg.get_categories(): for setting in self.def_cfg.get_settings(cat): self.widget_list[cat][setting].updateValue(self.def_cfg.get_setting(cat,setting)) elif button == self.main_apply: bad_settings = self.validate_settings() if bad_settings == []: self.save_settings() self.main_apply.setEnabled(False) self.main_reset.setEnabled(False) else: msgBox = QMessageBox() msgBox.setText("Must fix the following invalid settings before quitting:") msgBox.setStandardButtons(QMessageBox.Ok) info = '' for setting in bad_settings: new = '%s,%s<br>' % setting info = '%s%s' % (info, new) msgBox.setInformativeText(info) msgBox.exec_()
def save(self): mainlog.debug("EditTimeTracksDialog.save()") errors = self.controller.model.validate() if errors: showTableEntryErrorBox(errors) return False tt_start_time = datetime(self.edit_date.year, self.edit_date.month, self.edit_date.day, 6, 0, 0) edited_proxy_tts = self.controller.model.model_to_objects( lambda: TimetrackProxy()) employee_id = self.current_employee_id_selected # for tt in edited_proxy_tts: # mainlog.debug(type(tt)) # mainlog.debug(str(tt)) try: save_proxy_timetracks(edited_proxy_tts, tt_start_time, employee_id) return True except Exception as e: msgBox = QMessageBox(self) msgBox.setIcon(QMessageBox.Critical) msgBox.setText("There was an error while saving your data") msgBox.setInformativeText(str(e)) msgBox.setStandardButtons(QMessageBox.Ok) # msgBox.setDefaultButton(QMessageBox.Ok); ret = msgBox.exec_() return False
def check_editor_preferences(): # get preference values of external app path photo_dir = cmds.optionVar(exists='PhotoshopDir') image_dir = cmds.optionVar(exists='EditImageDir') # if there is no external app, request for an app path if not photo_dir and not image_dir: pref_warn = QMessageBox() pref_warn.setWindowTitle(WINDOW_TITLE) pref_warn.setIcon(QMessageBox.Warning) pref_warn.setText( '<b>Applications for Editing Image Files</b> ' 'is not set in your preferences.<br>' 'Maya needs it to send image in the right Image Editor ' 'instead of file system association.') pref_warn.setInformativeText('Do you want to select an application ?') pref_warn.setStandardButtons(QMessageBox.Yes | QMessageBox.No) pref_warn.setDefaultButton(QMessageBox.Yes) pref_warn.setEscapeButton(QMessageBox.Cancel) ret = pref_warn.exec_() if ret == QMessageBox.Yes: app_path = cmds.fileDialog2( fileFilter='Image editor application (*.exe)', caption='Select image editor application', startingDirectory=os.path.expandvars('%ProgramFiles%'), fileMode=1) if app_path is not None: cmds.optionVar(sv=('PhotoshopDir', app_path[0])) cmds.optionVar(sv=('EditImageDir', app_path[0]))
def error(self, error): if error == QNetworkSession.UnknownSessionError: msgBox = QMessageBox(self.parent()) msgBox.setText('This application requires network access to function.') msgBox.setInformativeText('Press Cancel to quit the application.') msgBox.setStandardButtons(QMessageBox.Retry | QMessageBox.Cancel) msgBox.setIcon(QMessageBox.Information) msgBox.setDefaultButton(QMessageBox.Retry) ret = msgBox.exec_() if ret == QMessageBox.Retry: QTimer.singleShot(0, self.session.open) elif ret == QMessageBox.Cancel: self.close() elif error == QNetworkSession.SessionAbortedError: msgBox = QMessageBox(self.parent()) msgBox.setText('Out of range of network') msgBox.setInformativeText('Move back into range and press Retry, or press Cancel to quit the application') msgBox.setStandardButtons(QMessageBox.Retry | QMessageBox.Cancel) msgBox.setIcon(QMessageBox.Information) msgBox.setDefaultButton(QMessageBox.Retry) ret = msgBox.exec_() if ret == QMessageBox.Retry: QTimer.singleShot(0, self.session.open) elif ret == QMessageBox.Cancel: self.close()
def verify_user(self, profileid=None): if profileid is None: profileid=self.current_profileid if len(profileid) == 0: return False try: username = gameslist.username_from_profile_id(profileid) except gameslist.NoSuchProfileError: return False if windows.desura_running(username): return True verify_dialog = QMessageBox() verify_dialog.setText("<b>Verify your identity</b><br />Sign in to Desura to continue with account <b>{0}</b> to confirm your identity".format(username)) verify_dialog.setInformativeText("<i>Waiting for Desura sign-in...</i>") verify_dialog.setWindowTitle("Sign into Desura to continue") verify_dialog.setStandardButtons(QMessageBox.Cancel) verify_dialog.setIcon(QMessageBox.Information) verify_dialog.setWindowFlags(Qt.CustomizeWindowHint | Qt.WindowTitleHint) desurawaiter = DesuraWaiter(username) desurawaiter.finished.connect(verify_dialog.close) desurawaiter.start() verify_dialog.exec_() if windows.desura_running(username): return True else: desurawaiter.terminate() return False
def _isCloseOk(self): doc = self.document if doc.saved: return True else: # current document has unsaved changes if doc.filePath is None: prefix = 'This document' else: fileName = os.path.basename(doc.filePath) prefix = 'The document "{:s}"'.format(fileName) box = QMessageBox() box.setText(prefix + ' has unsaved changes.') box.setInformativeText('Would you like to save them before closing?') box.setStandardButtons(QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel) box.setDefaultButton(QMessageBox.Save) result = box.exec_() if result == QMessageBox.Save: return self._onSave() elif result == QMessageBox.Cancel: return False else: return True
def onAbout(self): msgBox = QMessageBox(self) msgBox.setIconPixmap(QPixmap(":/images/sherlock.png")) msgBox.setWindowTitle(_translate("MainWindow", "Pythonthusiast", None)) msgBox.setText(_translate("MainWindow", "Well Watson, isn't it obvious to you that Qt rocks?", None)) msgBox.setStandardButtons(QMessageBox.Ok) msgBox.exec_()
def verify_user(self, profileid=None): if profileid is None: profileid = self.current_profileid if len(profileid) == 0: return False try: username = gameslist.username_from_profile_id(profileid) except gameslist.NoSuchProfileError: return False if windows.desura_running(username): return True verify_dialog = QMessageBox() verify_dialog.setText( "<b>Verify your identity</b><br />Sign in to Desura to continue with account <b>{0}</b> to confirm your identity" .format(username)) verify_dialog.setInformativeText( "<i>Waiting for Desura sign-in...</i>") verify_dialog.setWindowTitle("Sign into Desura to continue") verify_dialog.setStandardButtons(QMessageBox.Cancel) verify_dialog.setIcon(QMessageBox.Information) verify_dialog.setWindowFlags(Qt.CustomizeWindowHint | Qt.WindowTitleHint) desurawaiter = DesuraWaiter(username) desurawaiter.finished.connect(verify_dialog.close) desurawaiter.start() verify_dialog.exec_() if windows.desura_running(username): return True else: desurawaiter.terminate() return False
def help_gpus(self): msg = QMessageBox() msg.setIcon(QMessageBox.Question) msg.setText("Setting the number of GPUs") msg.setWindowTitle("Number of GPUs") if not self.HAVE_CUDA: info = "No GPUs are detected on your system" else: gpu_id = 0 is_available = True while is_available: try: cmt.cuda_set_device(gpu_id) is_available = True except Exception: is_available = False info = "%d GPU is detected on your system" % (gpu_id + 1) msg.setInformativeText("SpyKING CIRCUS can use several GPUs\n" "either locally or on multiple machine\n" "using MPI (see documentation)" "\n" "\n" "%s" % info) msg.setStandardButtons(QMessageBox.Close) msg.setDefaultButton(QMessageBox.Close) answer = msg.exec_()
def confirmationBox(text,info_text,object_name="confirmationBox"): """ Show a confirmation box to the user. :param text: Summary of the confirmation. :param info_text: Detailed message explaining what to confirm :param object_name: Name for Qt's object. :return: True if the user confirmed. False else. """ box = QMessageBox() box.setObjectName(object_name) box.setWindowTitle(_("Please confirm")) box.setIcon(QMessageBox.Question) _setBoxTexts(box,text,info_text) box.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel); # box.show() # from PySide.QtTest import QTest # from PySide.QtGui import QApplication # QTest.qWaitForWindowShown(box) # QApplication.instance().removePostedEvents() r = box.exec_() == QMessageBox.Ok box.deleteLater() return r
def cmdElimina_click(self): """Evento che gestisce il tasto di elimina""" msgBox = QMessageBox() if self.myWidget.lstRubrica.currentIndex(): index = self.myWidget.lstRubrica.currentIndex().row() rec = self.tableModel.record(index) nome = rec.value("nome") cognome = rec.value("cognome") msgBox.setText("Si conferma l'eliminazione del contatto %s %s?" % (nome, cognome)) msgBox.setInformativeText( "Se si procede con l'eliminazione il contatto verrà eliminato definitivamente." ) msgBox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) ret = msgBox.exec_() if (ret == QMessageBox.Ok): self.tableModel.removeRow(index) self.tableModel.submitAll() else: msgBox.setText("Occorre selezionare un elemento!") msgBox.exec_()
def editingFinishedHandler(self): settings = QSettings() old = settings.value("computation/reduce",QtReduceDefaults.REDUCE) new = self.reduceBinary.text() if old == new: return self.reduceBinary.blockSignals(True) tit = "Change Binary?" txt = self.tr("Do you really want to change this setting?") itxt = self.tr("If yes, then the binary ") itxt += '"' + new + '" ' itxt += self.tr("will be used at the next restart.") mbox = QMessageBox(self) mbox.setIcon(QMessageBox.Question) mbox.setWindowModality(Qt.WindowModal) mbox.setWindowTitle(tit) mbox.setText(txt) mbox.setInformativeText(itxt) mbox.setStandardButtons(QMessageBox.Yes|QMessageBox.No) button = mbox.exec_() if button == QMessageBox.Yes: settings.setValue("computation/reduce",new) else: self.reduceBinary.setText(old) self.reduceBinary.blockSignals(False)
def showdialog(x, y): msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText(x) msg.setInformativeText(y) msg.setWindowTitle("Alert") msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) return msg.exec_()
def makeInformationBox(text,info_text = None): warningBox = QMessageBox() warningBox.setWindowTitle(_("Information")) warningBox.setIcon(QMessageBox.Information) warningBox.setText(text); warningBox.setInformativeText(info_text) warningBox.setStandardButtons(QMessageBox.Ok); return warningBox
def yesNoBox(text,info_text,object_name="confirmationBox"): warningBox = QMessageBox() warningBox.setObjectName(object_name) warningBox.setWindowTitle(_("Please confirm")) warningBox.setIcon(QMessageBox.Question) _setBoxTexts(warningBox,text,info_text) warningBox.setStandardButtons(QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel); return warningBox.exec_()
def makeWarningBox(text,info_text,parent=None): warningBox = QMessageBox(parent) warningBox.setObjectName("warning_box") warningBox.setWindowTitle(_("Warning !")) warningBox.setIcon(QMessageBox.Warning) _setBoxTexts(warningBox,text,info_text) warningBox.setStandardButtons(QMessageBox.Ok); return warningBox
def make(title, text, icon=QMessageBox.Critical, buttons=QMessageBox.Ok, default_button=QMessageBox.Ok): ntfctn = QMessageBox() ntfctn.setWindowTitle(title) ntfctn.setText(text) ntfctn.setInformativeText(title) ntfctn.setStandardButtons(buttons) ntfctn.setDefaultButton(default_button) ntfctn.setIcon(icon) return ntfctn.exec_()
def error(title, text, buttons=QMessageBox.Ok, default_button=QMessageBox.Ok): msgBox = QMessageBox() msgBox.setWindowTitle(title) msgBox.setText(text) msgBox.setInformativeText(title) msgBox.setStandardButtons(buttons) msgBox.setDefaultButton(default_button) msgBox.setIcon(QMessageBox.Critical) return msgBox.exec_()
def user_choice(text, windowtitle, icon, acceptbutton="OK"): choice_dialog = QMessageBox() choice_dialog.setWindowIcon(QPixmap("../icons/desuratools_256.png")) choice_dialog.setText(text) choice_dialog.setIcon(icon) choice_dialog.setStandardButtons(QMessageBox.Cancel) choice_dialog.setWindowTitle(windowtitle) choice_dialog.addButton(acceptbutton, QMessageBox.AcceptRole) return choice_dialog
def _detail_error_msg(self, title, error_text, error_detailed_text): msg = QMessageBox(self.new_wallet_ui) msg.setWindowTitle(title) msg.setText(error_text) msg.setInformativeText("Detailed error information below:") msg.setDetailedText(error_detailed_text) msg.setIcon(QMessageBox.Critical) msg.setStandardButtons(QMessageBox.Ok) msg.exec_()
def reject(self): """exit the applicaiton if the user is sure""" box = QMessageBox() box.setStandardButtons(QMessageBox.Yes | QMessageBox.No) box.setText("Are you sure you want to exist?") ret = box.exec_() if ret == QMessageBox.Yes: QtGui.QApplication.exit()
def help_file_format(self): msg = QMessageBox() msg.setIcon(QMessageBox.Question) msg.setText("Supported file formats") msg.setWindowTitle("File formats") msg.setInformativeText("\n".join(list_all_file_format())) msg.setStandardButtons(QMessageBox.Close) msg.setDefaultButton(QMessageBox.Close) answer = msg.exec_()
def new_selected(self): msgBox = QMessageBox() msgBox.setText("Do you want to discard your changes?") msgBox.setStandardButtons(QMessageBox.Discard | QMessageBox.Cancel) msgBox.setDefaultButton(QMessageBox.Cancel) ret = msgBox.exec_() if ret == QMessageBox.Cancel: return self.filename = None self.apply_default()
def onExit(self): msgBox = QMessageBox(self) msgBox.setIcon(QMessageBox.Question) msgBox.setWindowTitle(_translate("MainWindow", "Pythonthusiast", None)); msgBox.setText(_translate("MainWindow", "Are you sure you want to quit?", None)) msgBox.setStandardButtons(QMessageBox.No|QMessageBox.Yes) msgBox.setDefaultButton(QMessageBox.Yes) msgBox.exec_ if msgBox.exec_() == QMessageBox.Yes: QtGui.qApp.quit()
def updateDialog(self): msgBox = QMessageBox() msgBox.setWindowTitle('Update available') msgBox.setText("There is a new version of AssetJet available.\n" \ "Do you want to download and install?") msgBox.setStandardButtons(QMessageBox.Yes | QtGui.QMessageBox.No) msgBox.setIcon(QMessageBox.Question) msgBox.setDefaultButton(QMessageBox.Yes) msgBox.setWindowIcon(QtGui.QIcon(':/Pie-chart.ico')) reply = msgBox.exec_() return reply
def _askAreYouSure(self): dialog_sure = QMessageBox(self) dialog_sure.setWindowTitle(self.tr("Confirm")) dialog_sure.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) dialog_sure.setIcon(QMessageBox.Warning) dialog_sure.setText(self.tr("Are you sure")) result = dialog_sure.exec_() if result == QMessageBox.Ok: return True else: return False
def __savediag(self): diag = QMessageBox(self) msg = 'Do you want to save the changes in your worksheet "' msg += (self.controller.fileName().split('/')[-1] or 'untitled') + '"?' diag.setText(msg) diag.setInformativeText("Otherwise they will get lost") diag.setIcon(QMessageBox.Warning) diag.setStandardButtons(QMessageBox.StandardButton.Discard | QMessageBox.StandardButton.Cancel | QMessageBox.StandardButton.Save) diag.setWindowModality(Qt.WindowModal) return diag.exec_()
def removeButtonClicked(self): """ Remove the last transformation in the list. """ messageBox = QMessageBox() messageBox.setText("The last transformation is about to be removed.") messageBox.setInformativeText("Do you want to proceed?") messageBox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) messageBox.setDefaultButton(QMessageBox.Ok) res = messageBox.exec_() if res == QMessageBox.Ok: self.transformationView.removeLastRow()
def show_dialog(message, title): msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText(title) msg.setInformativeText(message) msg.setWindowTitle("Something wrong occurred") msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) msg.buttonClicked.connect(QDataViewer.msgbtn) retval = msg.exec_() print "value of pressed message box button:", retval
def download_button_pressed(self): if self.ui.textEditDownload is not None: if self.check_url(self.ui.textEditDownload.toPlainText()): #subprocess.Popen(self.return_youtube_dl_cmd()) system(self.return_youtube_dl_cmd()) else: msgBox = QMessageBox() msgBox.setIcon(QMessageBox.Critical) msgBox.setText("Error in URL") msgBox.setInformativeText("Please check the URL you provided.") msgBox.setStandardButtons(QMessageBox.Ok) msgBox.exec_()
def run(app): # Ask user for AssetJet database location dlgDbLocation = DbLocation() # Hide the 'What's This' question mark dlgDbLocation.setWindowFlags(QtCore.Qt.WindowTitleHint) if dlgDbLocation.exec_(): loc = os.path.join(dlgDbLocation.getText(),'assetjet.db') # create directory if it doesn't exist yet if not os.path.exists(dlgDbLocation.getText()): os.mkdir(dlgDbLocation.getText()) cfg.add_entry('Database', 'DbFileName', loc) # Start download thread if database is not existing yet if not os.path.exists(loc): # Check internet connection from assetjet.util import util if util.test_url('http://finance.yahoo.com'): # Start download thread download = download_data.Downloader(loc) download.daemon = True download.start() # Create download progress dialog dlgProgress = QtGui.QProgressDialog( labelText='Downloading 1 year of daily returns for members of the S&P 500. \n This may take a couple of minutes.\n' , minimum = 0, maximum = 500, flags=Qt.CustomizeWindowHint | Qt.WindowTitleHint) dlgProgress.setWindowTitle('Downloading...') dlgProgress.setCancelButton(None) dlgProgress.setWindowIcon(QtGui.QIcon(':/Pie-chart.ico')) dlgProgress.show() # Update progress bar through signal download.downloaded.connect(dlgProgress.setValue) download.finished.connect(dlgProgress.close) app.exec_() # TODO: let it run in parallel with the local server thread download.wait() else: msgBox = QMessageBox() msgBox.setWindowTitle('No Internet Connection') msgBox.setText("To run AssetJet the first time, you need a working \n" \ "internet connection to download the historical returns.") msgBox.setStandardButtons(QMessageBox.Ok) msgBox.setIcon(QMessageBox.Warning) msgBox.setDefaultButton(QMessageBox.Ok) msgBox.setWindowIcon(QtGui.QIcon(':/Pie-chart.ico')) reply = msgBox.exec_() sys.exit()
def showCancelMessage(self): msgBox = QMessageBox() msgBox.setText("Are You Sure You Want To Cancel %s" % self.mode) msgBox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) msgBox.setDefaultButton(QMessageBox.Cancel) ret = msgBox.exec_() if ret == QMessageBox.Ok: self.end_process_early.value = 1 elif ret == QMessageBox.Cancel: self.paused.value = 0 self.pause_requested.value = 0 self.pause_sig_sent.value = 0 self.pause_requested.value = 0
def show_about(self): msg = QMessageBox() msg.setIcon(QMessageBox.Question) msg.setText("SpyKING CIRCUS v%s" % circus.__version__) msg.setWindowTitle("About") msg.setInformativeText("Documentation can be found at\n" "http://spyking-circus.rtfd.org\n" "\n" "Open a browser to see the online help?") msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No) msg.setDefaultButton(QMessageBox.No) answer = msg.exec_() if answer == QMessageBox.Yes: QDesktopServices.openUrl(QUrl("http://spyking-circus.rtfd.org"))
def closeEvent(self, event): msgBox = QMessageBox() msgBox.setText("Do you want to save before quitting?") msgBox.setInformativeText("Do you want to save your changes?") msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel) msgBox.setDefaultButton(QMessageBox.Save) ret = msgBox.exec_() if ret == QMessageBox.Save: self.save_file() event.accept() elif ret == QMessageBox.Discard: event.accept() else: event.ignore()
def newFile(self): """ Create a blank new file. """ if self.saved is False and self.editor.toPlainText() != '': msgBox = QMessageBox() msgBox.setText("The document has been modified.") msgBox.setInformativeText("really discard current document?") msgBox.setStandardButtons(QMessageBox.Discard | QMessageBox.Cancel) msgBox.setDefaultButton(QMessageBox.Cancel) ret = msgBox.exec_() if ret == QMessageBox.Cancel: return self.editor.clear() self.filename = ''
def _removeProfile_Dialog(self): """Runs a prompt dialog. Ask the user if he really wants to remove the selected profile. """ confirmationDialog = QMessageBox() confirmationDialog.setText("Do you really want to remove the selected profile ?") confirmationDialog.setInformativeText("Profile deletion can not be undone") confirmationDialog.setIcon(QMessageBox.Question) confirmationDialog.setStandardButtons(QMessageBox.Yes | QMessageBox.No) confirmationDialog.accepted.connect(self._emitRemoveProfile) ret = confirmationDialog.exec_() if ret==QMessageBox.Yes: self._emitRemoveProfile()
def show_alert_dialog(exception): msg = QMessageBox() msg.setIcon(QMessageBox.Warning) msg.setText("Something wrong occurred") msg.setInformativeText(str(exception.message)) msg.setWindowTitle("Something wrong occurred") msg.setDetailedText("The details are as follows:\n" + exception.message) print "The details are as follows:\n" + exception.message msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) msg.buttonClicked.connect(QDataViewer.msgbtn) retval = msg.exec_() print "value of pressed message box button:", retval
def on_override_panels(): """ Override HyperShade and NodeEditor creation callback""" override_info_box = QMessageBox() override_info_box.setWindowTitle(WINDOW_TITLE) override_info_box.setIcon(QMessageBox.Information) override_info_box.setText( 'Buttons will be added to HyperShade toolbar and Node Editor toolbar.<br/>' 'Changes will exists during this session.' ) override_info_box.setInformativeText('<i>Read Help to set this settings permanent</i>') override_info_box.setStandardButtons(QMessageBox.Ok) override_info_box.setDefaultButton(QMessageBox.Ok) override_info_box.exec_() mttOverridePanels.override_panels()
def on_override_panels(): """ Override HyperShade and NodeEditor creation callback""" override_info_box = QMessageBox() override_info_box.setWindowTitle(WINDOW_TITLE) override_info_box.setIcon(QMessageBox.Information) override_info_box.setText( 'Buttons will be added to HyperShade toolbar and Node Editor toolbar.<br/>' 'Changes will exists during this session.') override_info_box.setInformativeText( '<i>Read Help to set this settings permanent</i>') override_info_box.setStandardButtons(QMessageBox.Ok) override_info_box.setDefaultButton(QMessageBox.Ok) override_info_box.exec_() mttOverridePanels.override_panels()
def help_cpus(self): msg = QMessageBox() msg.setIcon(QMessageBox.Question) msg.setText("Setting the number of CPUs") msg.setWindowTitle("Number of CPUs") msg.setInformativeText("SpyKING CIRCUS can use several CPUs " "either locally or on multiple machines " "using MPI (see documentation) " "\n" "\n" "You have %d local CPUs available" % psutil.cpu_count()) msg.setStandardButtons(QMessageBox.Close) msg.setDefaultButton(QMessageBox.Close) answer = msg.exec_()
def ssl_errors(self, reply): try: self.replies.remove(reply) except KeyError: return False ca_cert = reply.sslConfiguration().peerCertificateChain()[-1] if not ca_cert.isValid(): self.message.setText( '<span style="font-size: 10px; color: #aa0000;">' + "Das Zertifikat ist nicht gültig." + "</span>" ) return False domain_list = [] for cert in reply.sslConfiguration().peerCertificateChain(): domain_list.append(cert.subjectInfo(cert.SubjectInfo.CommonName)) for key in cert.alternateSubjectNames().keys(): if type(key) == str and key[:3] == "DNS": domain_list.append(cert.alternateSubjectNames()[key]) print(extract_full_domain(self.url_edit.text())) print(domain_list) if extract_full_domain(self.url_edit.text()) not in domain_list: self.message.setText( '<span style="font-size: 10px; color: #aa0000;">' + "Das Zertifikat wurde für eine andere Domain ausgestellt." + "</span>" ) return False message_box = QMessageBox() message_box.setText("Ein unbekanntes CA-Zertifikat wurde gefunden.") message_box.setInformativeText( "Das Zertifikat hat den Fingerabdruck " + ":".join(re.findall("(.{2})", str(ca_cert.digest(QCryptographicHash.Sha1).toHex().toUpper()))) + ". Möchten Sie diesem Zertifikat vertrauen?" ) message_box.setStandardButtons(QMessageBox.No | QMessageBox.Yes) message_box.setDefaultButton(QMessageBox.Yes) answer = message_box.exec_() if answer != QMessageBox.Yes: self.message.setText( '<span style="font-size: 10px; color: #aa0000;">' + "Sie haben dem Zertifikat nicht vertraut." + "</span>" ) return False if not self.certificate: reply.ignoreSslErrors() self.certificate = ca_cert.toPem() self.save_settings() self.certificate_loaded.emit()
def ssl_errors(self, reply): try: self.replies.remove(reply) except KeyError: return False ca_cert = reply.sslConfiguration().peerCertificateChain()[-1] if not ca_cert.isValid(): self.message.setText( '<span style="font-size: 10px; color: #aa0000;">' + 'Das Zertifikat ist nicht gültig.' + '</span>') return False domain_list = [] for cert in reply.sslConfiguration().peerCertificateChain(): domain_list.append(cert.subjectInfo(cert.SubjectInfo.CommonName)) for key in cert.alternateSubjectNames().keys(): if type(key) == str and key[:3] == "DNS": domain_list.append(cert.alternateSubjectNames()[key]) print(extract_full_domain(self.url_edit.text())) print(domain_list) if extract_full_domain(self.url_edit.text()) not in domain_list: self.message.setText( '<span style="font-size: 10px; color: #aa0000;">' + 'Das Zertifikat wurde für eine andere Domain ausgestellt.' + '</span>') return False message_box = QMessageBox() message_box.setText("Ein unbekanntes CA-Zertifikat wurde gefunden.") message_box.setInformativeText( "Das Zertifikat hat den Fingerabdruck " + ":".join( re.findall( "(.{2})", str( ca_cert.digest( QCryptographicHash.Sha1).toHex().toUpper()))) + ". Möchten Sie diesem Zertifikat vertrauen?") message_box.setStandardButtons(QMessageBox.No | QMessageBox.Yes) message_box.setDefaultButton(QMessageBox.Yes) answer = message_box.exec_() if answer != QMessageBox.Yes: self.message.setText( '<span style="font-size: 10px; color: #aa0000;">' + 'Sie haben dem Zertifikat nicht vertraut.' + '</span>') return False if not self.certificate: reply.ignoreSslErrors() self.certificate = ca_cert.toPem() self.save_settings() self.certificate_loaded.emit()
def accept(self): """save the path var and exit""" items = [] for i in xrange(self.ui.pathList.count()): items.append(self.ui.pathList.item(i).text()) print items box = QMessageBox() box.setStandardButtons(QMessageBox.Yes | QMessageBox.No) box.setText("Are you sure you want to save?") ret = box.exec_() if ret == QMessageBox.Yes: envars.set_path(items) envars.broadcast_change() QtGui.QApplication.exit()
def stop_spider(self): if self._spider_id is None: # do not stop the the spider before receiving data pass else: if self._queue_check_timer.isActive(): confirm_stop = QMessageBox(self) confirm_stop.setIcon(QMessageBox.Warning) confirm_stop.setStandardButtons(QMessageBox.Yes | QMessageBox.No) confirm_stop.setText(self.tr("Scraping process still running")) confirm_stop.setDetailedText(self.tr("Are you sure you want to stop it?")) confirm_stop.setWindowTitle(self.tr("Spider still running")) ret = confirm_stop.exec_() if ret == QMessageBox.Yes: self.stop_spider_signal.emit(self._spider_id) return True else: return False # I won't whip you if you stop it accidentally else: return True # already over
def requestTabClose(self, tabIndex): tab_to_close = self._tab_widget.widget(tabIndex) response = tab_to_close.stop_spider() if response is True: # now make sure the user doesn't want the data confirm_close = QMessageBox(self) confirm_close.setStandardButtons(QMessageBox.Yes | QMessageBox.No) confirm_close.setIcon(QMessageBox.Warning) confirm_close.setText(self.tr("{0} data may be lost".format(self._tab_widget.tabText(tabIndex)))) confirm_close.setInformativeText(self.tr("Are you sure?")) confirm_close.setWindowTitle(self.tr("Warning")) ret = confirm_close.exec_() if ret == QMessageBox.Yes: self._tab_widget.removeTab(tabIndex) return True else: return False else: return False
def removeUnusedClips(self) : # Get selected items item = self.selectedItem proj = item.project() # Build a list of Projects SEQS = hiero.core.findItems(proj,"Sequences") # Build a list of Clips CLIPSTOREMOVE = hiero.core.findItems(proj,"Clips") # For each sequence, iterate through each track Item, see if the Clip is in the CLIPS list. # Remaining items in CLIPS will be removed for seq in SEQS: # Loop through selected and make folders... for track in seq: for trackitem in track: if trackitem.source() in CLIPSTOREMOVE: CLIPSTOREMOVE.remove(trackitem.source()) # If there are no Clips to remove, return if len(CLIPSTOREMOVE)==0: return # Present Dialog Asking if User wants to remove Clips msgBox = QMessageBox() msgBox.setWindowTitle("Remove Unused Clips"); msgBox.setText("Remove %i unused Clips from Project %s?" % (len(CLIPSTOREMOVE),proj.name())); msgBox.setDetailedText("Remove:\n %s" % (str(CLIPSTOREMOVE))); msgBox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel); msgBox.setDefaultButton(QMessageBox.Ok); ret = msgBox.exec_() if ret == QMessageBox.Cancel: return elif ret == QMessageBox.Ok: BINS = [] with proj.beginUndo('Remove Unused Clips'): # Delete the rest of the Clips for clip in CLIPSTOREMOVE: BI = clip.binItem() B = BI.parentBin() BINS+=[B] B.removeItem(BI)
def closeTab(self): if self.tabWidget.currentWidget().getSaved() is True: self.tabWidget.removeTab(self.tabWidget.currentWidget().getIndex()) else: confirmBox = QMessageBox() confirmBox.setText('The document has been modified.') confirmBox.setInformativeText('Do you want to save your changes?') confirmBox.setStandardButtons(QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel) confirmBox.setDefaultButton(QMessageBox.Save) confirm = confirmBox.exec_() if confirm == QMessageBox.Save: self.tabWidget.currentWidget().save() self.closeTab() elif confirm == QMessageBox.Discard: self.tabWidget.removeTab(self.tabWidget.currentWidget().getIndex()) elif confirm == QMessageBox.Cancel: pass else: raise ValueError(confirm)
def main(): additionallibpath = None app = QApplication(sys.argv) if "-help" in sys.argv or "-?" in sys.argv: msgBox = QMessageBox() msgBox.setText("Following arguments are possible:\t\t") msgBox.setInformativeText("-path\tPath to additional service libraries.\ne.g.: -path C:/plugins/bin") msgBox.setStandardButtons(QMessageBox.Ok) msgBox.exec_() return if "-path" in sys.argv: index = sys.argv.index("-path") additionallibpath = sys.argv[index+1] """ add additional service library path """ if additionallibpath: print "Additiona Library path:", additionallibpath QCoreApplication.addLibraryPath(additionallibpath); browser = ServiceBrowser() browser.show() return app.exec_()