我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用PyQt5.QtWidgets.QMessageBox.information()。
def extraction_done(self, outputs): nb_written_all, wrote_endpoints = 0, False for folder, output in outputs.items(): nb_written, wrote_endpoints = extractor_save(BASE_PATH, folder, output) nb_written_all += nb_written if wrote_endpoints: self.set_view(self.welcome) QMessageBox.information(self.view, ' ', '%d endpoints and their <i>.proto</i> structures have been extracted! You can now reuse the <i>.proto</i>s or fuzz the endpoints.' % nb_written_all) elif nb_written_all: self.set_view(self.welcome) QMessageBox.information(self.view, ' ', '%d <i>.proto</i> structures have been extracted! You can now reuse the <i>.protos</i> or define endpoints for them to fuzz.' % nb_written_all) else: self.set_view(self.choose_extractor) QMessageBox.warning(self.view, ' ', 'This extractor did not find Protobuf structures in the corresponding format for specified files.')
def save(self): """ Orders the AppController to save the current trained models. Parameters ---------- None Return ---------- None """ if self.controller.isTrained(): self.controller.save() QMessageBox.information(self.train, "Message", "Save succesful.") else: QMessageBox.warning(self.train, "Message", "Must have at least 1 trained classifier.")
def trainSystem(self): """ Orders the AppController to train a model based on the selected database. Parameters ---------- None Return ---------- None """ if self.path_train: trained = self.controller.train(self.path_train, self.comboBoxDatabaseTrain.currentText()) self.path_train = None if not trained: QMessageBox.critical(self.train, "Message", "File columns or labels mismatch.") else: QMessageBox.information(self.train, "Message", "Training succesful.") else: QMessageBox.warning(self.train, "Message", "Must pick a database file.")
def conflict_tags_submit(self): """ submit conflict tags :return: """ updata_tag_message_list = self.get_table_data() again_conflict_data = self.get_conflict_data(updata_tag_message_list) self.wait_dialog = WaitDialog(self) self.wait_dialog.setWindowModality(Qt.ApplicationModal) if again_conflict_data: message = str(again_conflict_data) + " has existed, whether to continue to submit" reply = QMessageBox.information(self, "merge conflicts", message, QMessageBox.Yes | QMessageBox.No) if reply == QMessageBox.Yes: self.wait_dialog.show() thread = Thread(target=self.case_data_manager.merge_conflict_data_callback, args=(updata_tag_message_list, self.callback)) thread.start() else: self.wait_dialog.show() thread = Thread(target=self.case_data_manager.merge_conflict_data_callback, args=(updata_tag_message_list, self.callback)) thread.start()
def closeEvent(self, close_even): if self.tag_id_line_edit.text() != '': if self.tag.name != self.tag_name_line_edit.text() or self.tag.description != self.tag_description_text_edit.toPlainText(): reply = QMessageBox.information(self, 'close window', 'Changes not saved, confirm close?', QMessageBox.Yes, QMessageBox.No) if reply != QMessageBox.Yes: close_even.ignore() return else: if self.tag_id_line_edit.text() != '' or self.tag_description_text_edit.toPlainText() != '': reply = QMessageBox.information(self, 'close window', 'Changes not saved, confirm close?', QMessageBox.Yes, QMessageBox.No) if reply != QMessageBox.Yes: close_even.ignore() return self.refresh_signal.emit()
def tag_save(self): tag_id = self.tag_id_line_edit.text() tag_name = self.tag_name_line_edit.text() tag_description = self.tag_description_text_edit.toPlainText() if tag_name == '' or tag_description == '': QMessageBox.warning(self, 'tag editor', 'tag name and description can\'t be empty') else: if len(tag_name) > 8: QMessageBox.warning(self, 'tag editor', 'tag name is not greater than 8 characters') else: if tag_id: self.tag.name = tag_name self.tag.description = tag_description self.db_helper.update_tag() QMessageBox.information(self, 'tag editor', 'tag update success')#todo ?????? else: tag = self.db_helper.query_tag_by_name(tag_name) if tag is None: tag = self.db_helper.insert_tag(tag_name, tag_description) self.tag_id_line_edit.setText(str(tag.id)) self.tag = tag QMessageBox.information(self, 'tag editor', 'tag insert success')#todo ?????? else: QMessageBox.warning(self, 'tag editor', 'tag has existed')
def connectToDatabase(db, user, psswrd, host): try: global conn conn = pymysql.connect( db=db, user=user, passwd=psswrd, host=host ) global data data = getAndSetData(conn) return conn, data except pymysql.err.OperationalError: Q = QMessageBox() Q = QMessageBox.information(Q, 'Error', 'Your username and/or password was incorrect. Please try again.', QMessageBox.Ok) return None, None
def acquire_vm_from_vmpool(self, rowid): """ Description: A machine will be acquired by a user if they click on the icon of a VmPool Arguments: The row id that has been clicked. This relationship is stored using the VmData class. Returns: Nothing """ self.lastclick = int(time()) # Last click timestamp update vmtype = self.vmdata[rowid].vmtype if vmtype == 'vmpool': try: QMessageBox.information(None, _('apptitle') + ': ' + _('info'), _('acquiring_vm_from_pool')) vmp = conf.OVIRTCONN.vmpools.get(id=self.vmdata[rowid].vmid) vmp.allocatevm() self.refresh_grid() except ConnectionError: QMessageBox.critical(None, _('apptitle') + ': ' + _('error'), _('unexpected_connection_drop')) quit() except RequestError: QMessageBox.critical(None, _('apptitle') + ': ' + _('error'), _('cannot_attach_vm_to_user')) else: QMessageBox.warning(None, _('apptitle') + ': ' + _('warning'), _('object_is_not_a_vmpool'))
def forget_creds(self): """ Description: Invoked when the user clicks on the 'Forget credentials' button in the toolbar. Arguments: None Returns: Nothing """ global conf self.lastclick = int(time()) # Last click timestamp update reply = QMessageBox.question(None, _('apptitle') + ': ' + _('confirm'), _('confirm_forget_creds'), QMessageBox.Yes | QMessageBox.No, QMessageBox.No) if reply == QMessageBox.Yes: remove(conf.USERCREDSFILE) self.forgetCredsAction.setDisabled(True) QMessageBox.information(None, _('apptitle') + ': ' + _('success'), _('creds_forgotten'))
def upgrade(self): response = QMessageBox.question( self.anki.window(), 'AnkiConnect', 'Upgrade to the latest version?', QMessageBox.Yes | QMessageBox.No ) if response == QMessageBox.Yes: data = download(URL_UPGRADE) if data is None: QMessageBox.critical(self.anki.window(), 'AnkiConnect', 'Failed to download latest version.') else: path = os.path.splitext(__file__)[0] + '.py' with open(path, 'w') as fp: fp.write(makeStr(data)) QMessageBox.information(self.anki.window(), 'AnkiConnect', 'Upgraded to the latest version, please restart Anki.') return True return False
def calculateDalpha(self): try: a_par = self.ui.alpha_par.text(); a_perp = self.ui.alpha_perp.text(); if (a_par == ""): a_par = "0"; if (a_perp == ""): a_perp = "0"; self.ui.deltaAlpha.setText(str(round(float(a_par)-float(a_perp),5))); except ValueError: self.ui.deltaAlpha.setText(""); # try: # result = QMessageBox.information(QWidget(),'Information','Some informative text'); # print(result); # result = QMessageBox.warning(QWidget(),'Warn','WARNONNN!'); # result = QMessageBox.warning(QWidget(),'Warn','WARNONNN!'); # print(result); # self.enable_save_option(); # finally: # self.enable_Go_button(); #
def calculate(self): inputs = self.validate_input(); if (inputs is not False): Jmax,Kmax,Mmax = inputs; self.setEnabled(False); self.update(); QMessageBox.information(self,'Responsiveness','This user interface will be irresponsive while the calculation is carried out.\n\nSorry about that!'); try: U2dcalc.set_num_threads(multiprocessing.cpu_count()); U2dcalc.precalculate_matrix_elements(Jmax,Kmax,Mmax); self.update_available(); QMessageBox.information(self,'Success!','Calculation done.'); self.close(); except BaseException as e: QMessageBox.critical(self,'Failed to calculate matrix elements',str(e)); self.setEnabled(True); else: QMessageBox.critical(self,'Validation error',"Invalid input");
def slot_new(self): """ ???? ?? ? ?? :return: """ if not self.is_saved: reply = QMessageBox.information( self, self.tr("Save"), self.tr("??? ??? ?????????"), QMessageBox.Save | QMessageBox.No | QMessageBox.Cancel, QMessageBox.Save) if reply == QMessageBox.Save: if not self.slot_save(): return # ?? ?? elif reply == QMessageBox.No: pass else: return # ?? ?? self.init_setting()
def saveDesign_inputs(self): fileName,_ = QFileDialog.getSaveFileName(self,"Save Design", os.path.join(str(self.folder), "untitled.osi"),"Input Files(*.osi)") if not fileName: return try: out_file = open(str(fileName), 'wb') except IOError: QMessageBox.information(self, "Unable to open file", "There was an error opening \"%s\"" % fileName) return # yaml.dump(self.uiObj,out_file,allow_unicode=True, default_flow_style=False) json.dump(self.uiobj, out_file) out_file.close()
def displaylog_totextedit(self, commLogicObj): ''' This method displaying Design messages(log messages)to textedit widget. ''' fname = str(commLogicObj.call_saveMessages()) afile = QFile(fname) if not afile.open(QIODevice.ReadOnly): # ReadOnly QMessageBox.information(None, 'info', afile.errorString()) stream = QTextStream(afile) self.ui.textEdit.clear() self.ui.textEdit.setHtml(stream.readAll()) vscroll_bar = self.ui.textEdit.verticalScrollBar() vscroll_bar.setValue(vscroll_bar.maximum()) afile.close()
def login_click(self): string = '' ID = self.inputID.text() passwd = self.inputPW.text() result = mysign.login(ID, passwd, s, key) if result == 1: QMessageBox.warning(self, '???', '??? ?? ????? ?? ????.') elif result == 3: QMessageBox.warning(self, '???', '??? ?? ????? ???? ????') else: QMessageBox.information(self, '???', result + '?, ?????.') user_info['username'] = result user_info['account'] = ID self.tmp = MainForm() self.hide() self.tmp.draw() self.inputID.setText("") self.inputPW.setText("")
def check_btn_click(self): ID = self.inputID.text() if len(ID) < 5 or len(ID) > 20: QMessageBox.warning(self, '?? ??', '???? 5???? 20?? ??? ?????.') self.inputID.setText("") return elif len(ID) > 5 or len(ID) < 20: string = mysign.overlap(ID, s, key) if string == 'success': QMessageBox.information(self, '?? ??', '?? ??? ??? ???') self.i = 1 else: QMessageBox.warning(self, '?? ??', '?? ???? ??? ???.') self.inputID.setText("")
def with_btn_click(self): if self.input_PW.text() == '': QMessageBox.warning(self, '?? ??', '????? ??? ???') return answer = QMessageBox.warning(self, '?? ??', '??? ?? ???????\n??? ??? ??? ??????.', QMessageBox.Ok|QMessageBox.No) if (answer == QMessageBox.No): return else: QMessageBox.information(self, '??? ??', '?? ????') """ mysocket.sendMsg(s, '2', key) mysocket.sendMsg(s, self.input_PW.text(), key) result = mysocket.getMsg(s, key) if result == 'PW different' or result == 'PW different ': QMessageBox.warning(self, '?? ??', '?? ?? ??') return else: QMessageBox.information(self, '?? ??', '???? ??????. ??~') ??? ???. """
def fuzz_endpoint(self): QMessageBox.information(self.view, ' ', 'Automatic fuzzing is not implemented yet.')
def validateSystem(self): """ Orders the AppController to validate a model based on the selected database. Parameters ---------- None Return ---------- None """ if self.path_validate: checked, validated, accuracy, precision, sensitivity, specificity, kappa = self.controller.validate(self.path_validate, self.spinBoxFolds.value(), self.comboBoxDatabaseValidate.currentText()) self.path_validate = None if not validated: QMessageBox.warning(self.validate, "Message", "Classifier for "+ self.comboBoxDatabaseValidate.currentText() + " database is not trained.") self.clearValidateLineEdits() else: self.lineEditAccuracy.setText(str(accuracy)) self.lineEditPrecision.setText(str(precision)) self.lineEditSensitivity.setText(str(sensitivity)) self.lineEditSpecificity.setText(str(specificity)) self.lineEditKappa.setText(str(kappa)) QMessageBox.information(self.train, "Message", "Validation finished.") if not checked: QMessageBox.critical(self.validate, "Message", "File columns or labels mismatch.") self.clearValidateLineEdits() else: QMessageBox.warning(self.validate, "Message", "Must pick a database file.") self.clearValidateLineEdits()
def _show_wiring(self): wiring = "RST\t-> RTS\n" \ "GPIO0\t-> DTR\n" \ "TXD\t-> RXD\n" \ "RXD\t-> TXD\n" \ "VCC\t-> 3V3\n" \ "GND\t-> GND" QMessageBox.information(self, "Wiring", wiring)
def closeEvent(self, event): if self.trayIcon.isVisible() and not self.user_closed: QMessageBox.information( self, "Bitmask", "Bitmask will minimize to the system tray. " "You can choose 'Quit' from the menu with a " "right click on the icon, and restore the window " "with a double click.") self.hide() if not self.user_closed: event.ignore()
def onCalculationFinish(self): self.textEdit.append('????????? ?? ' + self.profiler.stop() + ' ?.') QApplication.restoreOverrideCursor() QMessageBox.information(self, "????????", "??????? ????????????? ????????!") # ????? ??? ??????? ?? ?????? "????????????????"
def onCalculationFinish(self): self.textEdit.append('????????? ?? ' + self.profiler.stop() + ' ?.') QApplication.restoreOverrideCursor() QMessageBox.information(self, "????????", "??????: MI, IG, ??-??????? ????????!")
def onCalculationFinish(self, xs, ys, similarity, short_filenames): self.textEdit.append('????????? ?? ' + self.profiler.stop() + ' ?.') self.xs = xs self.ys = ys self.similarity = similarity self.short_filenames = short_filenames QApplication.restoreOverrideCursor() self.button2DView.setEnabled(True) self.buttonRelationTable.setEnabled(True) self.buttonMakeLSA.setEnabled(True) QMessageBox.information(self, "????????", "????????-????????????? ?????? ????????!")
def on_calculation_finish(self): self.textEdit.append('????????? ?? ' + self.profiler.stop() + ' ?.') QApplication.restoreOverrideCursor() self.buttonProcess.setEnabled(True) QMessageBox.information(self, "????????", "?????????????? ????????????? ?????????!")
def onCalculationFinish(self): # self.groupButtonsBox.setEnabled(True) self.textEdit.append('????????? ?? ' + self.profiler.stop() + ' ?.') QApplication.restoreOverrideCursor() QMessageBox.information(self, "????????", "??????? ????????????? ????????!") # ????? ??? ??????? ?? ?????? "????????????????"
def onCalculationFinish(self): self.tabWidget.setEnabled(True) self.textEdit.append('????????? ?? ' + self.profiler.stop() + ' ?.') QApplication.restoreOverrideCursor() self.addfig(plt.gcf()) self.startMethod.setEnabled(True) self.checkBoxNeedCalculateTFIDF.setEnabled(True) QMessageBox.information(self, "????????", "????????????? ?????????!")
def set_content_image(self, list_image, des_dir): self.content_text_browser.clear() self.content_text_browser.setEnabled(True) for i in list_image: full_path = html.escape(des_dir + '/' + PurePath(i).name) self.content_text_browser.append( "<img src='{}' title='store at : {}'/><br/>".format(full_path, full_path)) self.__load_finished() QMessageBox.information(self, 'Download Completed', 'All of your donwload images store at : {}'.format(des_dir))
def handle_error_occurred(self): QMessageBox.information(self, 'Not Found', 'Title or Lang Not Found') self.content_text_browser.clear() self.content_text_browser.setEnabled(False) self.__load_finished()
def connection(): conn, data = SQL_Handler.connectToDatabase('fobs', form.UsernameField.text(), form.PasswordField.text(), 'localhost') if conn is not None: buildTable() form.close() form2.show() form2.logoutButton.clicked.connect(mainMenu) form2.refreshButton.clicked.connect(lambda: buildTable()) form2.validationButton.clicked.connect(lambda: saveChanges()) else: Q = QMessageBox() Q = QMessageBox.information(Q, 'Error', 'Connection failed.', QMessageBox.Ok)
def submitContact(self): name = self.nameLine.text() address = self.addressText.toPlainText() if name == "" or address == "": QMessageBox.information(self, "Empty Field", "Please enter a name and address.") return if name not in self.contacts: self.contacts[name] = address QMessageBox.information(self, "Add Successful", "\"%s\" has been added to your address book." % name) else: QMessageBox.information(self, "Add Unsuccessful", "Sorry, \"%s\" is already in your address book." % name) return if not self.contacts: self.nameLine.clear() self.addressText.clear() self.nameLine.setReadOnly(True) self.addressText.setReadOnly(True) self.addButton.setEnabled(True) self.submitButton.hide() self.cancelButton.hide()
def change_status(self, rowid): """ Description: If the user clicks on the column which determines VM's status, we'll allow them to change VM's status. This method shows a confirmation dialog and if accepted, it will be notified to oVirt. Arguments: The row id that has been clicked. This relationship is stored using the VmData class. Returns: Nothing """ global conf self.lastclick = int(time()) # Last click timestamp update curvmstatus = self.vmdata[rowid].vmstatus if curvmstatus != 'up' and curvmstatus != 'down': QMessageBox.warning(None, _('apptitle') + ': ' + _('warning'), _('vm_in_unchangeable_status')) return reply = QMessageBox.question(None, _('apptitle') + ': ' + _('confirm'), '%s <b>%s</b>. %s: <b>%s</b>.' % (_('current_vm_status'), self.current_vm_status(curvmstatus), _('confirm_vm_status_change'), self.toggle_vm_action(curvmstatus)), QMessageBox.Yes | QMessageBox.No, QMessageBox.No) if reply == QMessageBox.Yes: try: vm = conf.OVIRTCONN.vms.get(id=self.vmdata[rowid].vmid) except ConnectionError: QMessageBox.critical(None, _('apptitle') + ': ' + _('error'), _('unexpected_connection_drop')) quit() if curvmstatus == 'up': try: vm.shutdown() QMessageBox.information(None, _('apptitle') + ': ' + _('success'), _('shutting_down_vm')) except RequestError: QMessageBox.warning(None, _('apptitle') + ': ' + _('warning'), _('vm_in_unchangeable_status')) if curvmstatus == 'down': try: vm.start() QMessageBox.information(None, _('apptitle') + ': ' + _('success'), _('powering_up_vm')) except RequestError: QMessageBox.warning(None, _('apptitle') + ': ' + _('warning'), _('vm_in_unchangeable_status'))
def help(self): helpmsg = "It may be helpful to hover the mouse cursor over\n"; helpmsg += "items and text labels that you don't understand."; QMessageBox.information(self,'Nonadiabatic help',helpmsg);
def no_user_selected(self): reply = message.information(self, 'No User Selected', no_user_selected_message, message.Ok) return reply == message.Ok
def no_subreddit_selected(self): reply = message.information(self, 'No Subreddit Selected', no_subreddit_selected_message, message.Ok) return reply == message.Ok
def failed_to_save(self): reply = message.information(self, 'Save Failed', failed_to_save_message, message.Ok) return reply == message.Ok
def remove_user(self): reply = message.information(self, 'Remove User?', remove_user_message, message.Ok, message.Cancel) return reply == message.Ok
def remove_subreddit(self): reply = message.information(self, 'Remove Subreddit?', remove_subreddit_message, message.Ok, message.Cancel) 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 not_valid_name(self): text = 'Sorry, that is not a valid name' reply = message.information(self, 'Invalid Name', text, message.Ok) return reply == message.Ok
def name_in_list(self): text = 'That name is already in the list' reply = message.information(self, 'Existing Name', text, message.Ok) return reply == message.Ok
def no_user_download_folder(self): text = 'The user you selected does not appear to have a download folder. This is likely because nothing has ' \ 'been downloaded for this user yet.' reply = message.information(self, 'Folder Does Not Exist', text, message.Ok) return reply == message.Ok
def no_subreddit_download_folder(self): text = 'The subreddit you selected does not appear to have a download folder. This is likely because nothing ' \ 'has been downloaded for this subreddit yet.' reply = message.information(self, 'Folder Does Not Exist', text, message.Ok) return reply == message.Ok
def nothing_to_download(self): text = 'Nothing to download. Please add users or subreddits you would like to download from.' reply = message.information(self, 'Nothing to Download', text, message.Ok) return reply == message.Ok
def no_imgur_client(self): text = 'No Imgur client is detected. You must have an Imgur client in order to download content from ' \ 'imgur.com. Please see settings menu and click on the "Imgur Client Information" in the top right for ' \ 'instuctions on how to obtain an imgur client and enter its credentials for use with this application' reply = message.information(self, 'No Imgur Client', text, message.Ok) return reply == message.Ok
def invalid_imgur_client(self): text = 'The Imgur client you are useing is not valid. Please see the imgur client dialog for instructions on ' \ 'how to obtain a valid client id and secret. This dialog can be accessed through the settings menu' reply = message.information(self, 'Invalid Imgur Client', text, message.Ok) return reply == message.Ok
def user_manual_not_found(self): text = 'The user manual cannot be found. This is most likely because the manual has been moved from the ' \ 'expected location, or renamed to something the application is not expecting. To correct the issue ' \ 'please move the user manual back to the source folder and ensure it is named ' \ '"The Downloader For Reddit - User Manual.pdf"' reply = message.information(self, 'User Manual Not Found', text, message.Ok) return reply == message.Ok
def up_to_date_message(self): text = 'You are running the latest version of The Downloader for Reddit' reply = message.information(self, 'Up To Date', text, message.Ok) return reply == message.Ok