def inserted(): msg = QMessageBox() msg.setText(" Sucessos ") msg.setInformativeText("Os Dados Foram inseridos com sucesso na base de dados") msg.setIcon(QMessageBox.Information) msg.setStandardButtons(QMessageBox.Ok) msg.exec()
def updated(txt): msg = QMessageBox() msg.setText(" Sucessos ") msg.setInformativeText("Os Dados Foram Atualizados onde: "+txt+" na base de dados") msg.setIcon(QMessageBox.Information) msg.setStandardButtons(QMessageBox.Ok) msg.exec()
def _save_dialog(self, parent, title, msg, det_msg=''): d = QMessageBox(parent) d.setWindowTitle(title) d.setText(msg) d.setStandardButtons(QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel) return d.exec_()
def aviso(txt): msg = QMessageBox() msg.setText(" Aviso ") msg.setInformativeText(txt) msg.setIcon(QMessageBox.Warning) msg.setStandardButtons(QMessageBox.Ok) msg.exec_()
def step_dialog(parent, title, msg, det_msg=''): d = QMessageBox(parent) d.setWindowTitle(title) d.setText(msg) d.setStandardButtons(QMessageBox.StandardButton.Ok | QMessageBox.StandardButton.Cancel) return d.exec_() & QMessageBox.StandardButton.Cancel
def msgBox(self): msgBox = QMessageBox() msgBox.setWindowTitle("경고창") # 메세지창의 상단 제목 msgBox.setText("돌이 이미 있습니다") # 메세지 내용 msgBox.setStandardButtons(QMessageBox.Yes) msgBox.exec_() msgBox.show()
def display_info(self, text: str): message_box = QMessageBox() message_box.setIcon(QMessageBox.Information) message_box.setWindowTitle("Information") message_box.setText(text) message_box.setStandardButtons(QMessageBox.Ok) message_box.exec_()
def Sucessos(txt): msg = QMessageBox() msg.setWindowTitle("Sucesso") msg.setText(" Sucessos ") msg.setInformativeText(txt) msg.setIcon(QMessageBox.Information) msg.setStandardButtons(QMessageBox.Ok) msg.exec()
def display_error(self, text: str): message_box = QMessageBox() message_box.setIcon(QMessageBox.Critical) message_box.setWindowTitle("Error") message_box.setText(text) message_box.setStandardButtons(QMessageBox.Ok) message_box.exec_()
def show_messagebox(message, title, icon=QMessageBox.Information): msg_box = QMessageBox() msg_box.setIcon(icon) msg_box.setText(message) # msg_box.setInformativeText(message) msg_box.setWindowTitle(title) # msg_box.setDetailedText("The details are as follows:") msg_box.setStandardButtons(QMessageBox.Ok) retval = msg_box.exec_()
def show_warning(text): """ Shows a simple warning with given text. """ msg_box = QMessageBox() msg_box.setText(text) msg_box.setStandardButtons(QMessageBox.Ok) msg_box.setDefaultButton(QMessageBox.Ok) msg_box.exec()
def display_error(text: str): """Displays an error message to the user.""" message = QMessageBox() message.setIcon(QMessageBox.Critical) message.setWindowTitle("Error") message.setText(text) message.setStandardButtons(QMessageBox.Ok) message.exec_()
def is2insert(txt="Tem a certaza que gostari de realizar essa operacao?"): msg = QMessageBox() msg.setText(" Confirmacao ") msg.setInformativeText(txt) msg.setIcon(QMessageBox.Question) msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No) clicked = msg.exec() resp = True if clicked == QMessageBox.Yes else False return resp
def message_box(self, text, informative, icon, buttons=QMessageBox.Ok): """Wraps up the QMessageBox""" msg = QMessageBox(self) msg.setStandardButtons(buttons) msg.setDefaultButton(QMessageBox.Ok) msg.setText(text) msg.setInformativeText(informative) msg.setIcon(icon) return msg.exec_()
def documentIsNotSave(parent): msgBox = QMessageBox(parent) msgBox.setWindowTitle('The document has been modified') msgBox.setText('The document has been modified') msgBox.setInformativeText('Do you want to save your change?') msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel) msgBox.setDefaultButton(QMessageBox.Save) msgBox.setIcon(QMessageBox.Warning) return msgBox.exec_()
def message_yes_no_cancel(self, question: str, yes: str, no: str) -> int: box = QMessageBox() box.setIcon(QMessageBox.Question) box.setWindowTitle("Photocopieuse") box.setText(question) box.setStandardButtons(QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel) btYes = box.button(QMessageBox.Yes) btYes.setText(yes) btNo = box.button(QMessageBox.No) btNo.setText(no) return box.exec_()
def show_discard_data_ok_cancel_message(): """Shows a QMessageBox to ask if the current mpdj data should be discarded. Contains an OK and an Cancel Button.""" msg = QMessageBox() msg.setIcon(QMessageBox.Question) msg.setText("You have unsaved changes in your current Data. Discard\ unsaved changes and proceed?") msg.setInformativeText("Unsaved changes will be lost.") msg.setWindowTitle("Unsaved changes") msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) retval = msg.exec_() return retval
def error(txt=None, verbTxt=None): msg = QMessageBox() msg.setText(" Error ") if txt is None and verbTxt is None: msg.setInformativeText("Erro Algo aconteceu tente De novo.") elif txt is not None and verbTxt is None: msg.setInformativeText(txt) else: msg.setInformativeText(txt) msg.setDetailedText(verbTxt) msg.setIcon(QMessageBox.Warning) msg.setStandardButtons(QMessageBox.Ok) msg.exec()
def Sucessos(txt): msg = QMessageBox() msg.setText(" Sucessos ") msg.setInformativeText(txt) msg.setIcon(QMessageBox.Information) msg.setStandardButtons(QMessageBox.Ok) msg.exec() #=============================================================================== # if __name__=="__main__": # app = QApplication(sys.argv) # screen = Soft_Warning("Erro nº:1 \nPorfavor tente de novo.") # print(screen) # sys.exit(app.exec_()) #===============================================================================
def updateGame(self): self.game.updateAll() self.checkButtons() self.drawEnemies() self.drawTowers() self.drawProjectiles() self.checkGameOver() self.updatePlayerStats() if self.game.over: box = QMessageBox() box.setWindowTitle("Game Over") box.setText("You got "+str(self.game.player.points)+" points.") box.setStandardButtons(QMessageBox.Ok) box.buttonClicked.connect(self.closeGui) retval = box.exec_()
def save_mpdj_data_to_file(self, p_file_name: str): """Saves the current mpdj data to the file by the path given in p_file_name.""" try: global_properties = GlobalProperties.get_instance() global_properties.save_mpdj_data_to_file(p_file_name) self.statusBar().showMessage('Saved to {}'.format(p_file_name), 5000) except (OSError, IOError) as exception: message_box = QMessageBox() message_box.setText('Error saving the file: {}'.format( str(exception))) message_box.setWindowTitle('Error saving the file.') message_box.setStandardButtons(QMessageBox.Ok) message_box.setIcon(QMessageBox.Warning) message_box.exec_()
def show_success(self): message = QMessageBox(self.gui) message.setIcon(QMessageBox.Information) message.setText("KiPEO has compleletly reshaped your e-book.\r\n\r\nWould you like to see what we have changed?") message.setWindowTitle("KiPEO") message.setStandardButtons(QMessageBox.Yes | QMessageBox.No) message.show() user_choice = message.exec_() if user_choice == QMessageBox.Yes: #Show the user what changes we have made, allowing her to #revert them if necessary self.boss.show_current_diff() #Update the editor UI to take into account all the changes we #have made self.boss.apply_container_update_to_gui()
def file_load(self): """Loads mpdj data from a file. Opens a file dialog which asks for the file to load.""" global_properties = GlobalProperties.get_instance() file_name = self.file_dialog(load_save_type=QFileDialog.AcceptOpen) if file_name: if global_properties.changes_happened_since_last_save: retval = show_discard_data_ok_cancel_message() if not global_properties.changes_happened_since_last_save or retval == QMessageBox.Ok: try: global_properties.load_mpdjdata_from_file(file_name) except AttributeError as err: message_box = QMessageBox() message_box.setText( 'Error reading your MPDJ-File: {}'.format(err)) message_box.setWindowTitle('Load error.') message_box.setStandardButtons(QMessageBox.Ok) message_box.setIcon(QMessageBox.Warning) message_box.exec_()
def remove_tab(self, index): widget = self.widget(index) if self.file_helper.is_dirty(widget, widget.toPlainText()): box = QMessageBox() box.setIcon(QMessageBox.Question) box.setText("If you continue you will lose your changes\n" + "Would you like to continue?") box.setWindowTitle("Unsaved Changes") box.setStandardButtons(QMessageBox.Yes | QMessageBox.No) val = box.exec() if val == QMessageBox.No: return if widget is not None: widget.deleteLater() self.removeTab(index) self.file_helper.remove_key(widget) if widget in self.ontologies.keys(): self.ontologies.pop(widget, None)
def select_load_dataset_mode(self): box = QMessageBox() box.setIcon(QMessageBox.Question) box.setWindowTitle('load seed') box.setText( "Please Select the way to load the seed, " "you can load in new config or load in current config (will overwrite current seeds)!" ) box.setStandardButtons(QMessageBox.Ok | QMessageBox.No | QMessageBox.Cancel) creat_config = box.button(QMessageBox.Ok) creat_config.setText('New') replace_config = box.button(QMessageBox.No) replace_config.setText('Replace') box.exec_() if box.clickedButton() == creat_config: self.on_createConfig_clicked() self.load_seeds(seed_path=self.ui.seedPath.text()) elif box.clickedButton() == replace_config: self.load_seeds(seed_path=self.ui.seedPath.text()) else: self.ui.seedPath.setText('')
def borrado_fila(): #borrado fila de la tabla global fila, id_fila fila = vt.tbl_tabla.currentRow() id_fila = vt.tbl_tabla.item(fila, 0).text() #se crea MessageBox personalizado de confirmación de borrado: confirmacion = QMessageBox(tabla) confirmacion.setIcon(QMessageBox.Warning) confirmacion.setWindowTitle("Confirmación") confirmacion.setInformativeText("¿Seguro que deseas borrar\nla fila " + str(fila + 1) + "?") confirmacion.setStandardButtons(QMessageBox.Yes | QMessageBox.Cancel) confirmacion.setDefaultButton(QMessageBox.Cancel) boton_yes = confirmacion.button(QMessageBox.Yes) boton_yes.setText("Aceptar") boton_cancel = confirmacion.button(QMessageBox.Cancel) boton_cancel.setText("Cancelar") respuesta = confirmacion.exec_() if respuesta == QMessageBox.Yes: base.query_delete_comic(id_fila) if Path("portadas/" + str(id_fila) + ".jpg").is_file(): os.remove("portadas/" + str(id_fila) + ".jpg") abrir_ventana_tabla()
def file_dialog(self, load_save_type=QFileDialog.AcceptSave): """Opens an file save dialog and returns the selected filename.""" file_save_dialog = QFileDialog(self) file_save_dialog.setFileMode(QFileDialog.AnyFile) file_save_dialog.setAcceptMode(load_save_type) file_save_dialog.setNameFilters( ["MPDJ files (*.{})".format(FILE_SUFFIX)]) file_save_dialog.selectNameFilter( "MPDJ files (*.{})".format(FILE_SUFFIX)) file_save_dialog.setDefaultSuffix((FILE_SUFFIX)) exec_value = file_save_dialog.exec() if exec_value == 0: return None file_names = file_save_dialog.selectedFiles() if len(file_names) != 1: message_box = QMessageBox() message_box.setText('Please select only one file!') message_box.setWindowTitle('Save error.') message_box.setStandardButtons(QMessageBox.Ok) message_box.setIcon(QMessageBox.Information) message_box.exec_() return None return file_names[0]
def save_settings(self): self.plugin_prefs.set('inspector_enabled', self.inspector_checkbox.isChecked()) self.plugin_prefs.set('beta_mode', self.beta_checkbox.isChecked()) # # If restart needed, inform user if self.restart_required: # do_restart = show_restart_warning('Restart calibre for the changes to be applied.', # parent=self.l) # if do_restart: # self.gui.quit(restart=True) # TODO: figure out if theres a way to call self.gui.quit() msg = QMessageBox() msg.setIcon(QMessageBox.Warning) msg.setText("Restart Required") msg.setInformativeText( "A configuration change requires you to restart Calibre, You should do so now," ) msg.setWindowTitle("Restart Required") msg.setStandardButtons(QMessageBox.Ok) msg.exec_()
class MessageWindow: def __init__(self, title, text, type="ok", default=None, customButtons=None, customIcon=None, run=True, destroyAfterRun=True, detailed=False, longText=""): self.rc = None self.dialog = None self.msgBox = QMessageBox() self.doCustom = False self.customButtons = customButtons icon = None buttons = None if type == 'ok': buttons = QMessageBox.Ok icon = "question" elif type == 'error': icon = "error" buttons = QMessageBox.Ok elif type == 'warning': icon = "warning" buttons = QMessageBox.Ok elif type == 'okcancel': icon = "question" buttons = QMessageBox.Ok | QMessageBox.Cancel elif type == 'question': icon = "question" buttons = QMessageBox.Ok | QMessageBox.Cancel elif type == 'yesno': icon = "question" buttons = QMessageBox.Yes | QMessageBox.No elif type == 'custom': self.doCustom = True if customIcon: icon = customIcon else: icon = "question" text = "<qt>%s</qt>" % text.replace("\n", " ") self.msgBox.setText(text) if detailed: self.msgBox.setDetailedText(unicode(longText)) if self.doCustom: button = None for index, text in enumerate(self.customButtons): button = self.msgBox.addButton(text, QMessageBox.ActionRole) if default is not None and default == index: self.msgBox.setDefaultButton(button) else: self.msgBox.setStandardButtons(buttons) if default == "no": default = QMessageBox.No elif default == "yes": default = QMessageBox.Yes elif default == "ok": default = QMessageBox.Ok else: default = None self.msgBox.setDefaultButton(default) self.dialog = Dialog(_(title), self.msgBox, closeButton=False, isDialog=True, icon=icon) self.dialog.resize(QSize(0, 0)) if run: self.run(destroyAfterRun) def run(self, destroyAfterRun=True): self.rc = self.dialog.exec_() if self.msgBox.clickedButton(): if not self.doCustom: if self.msgBox.clickedButton().text() in [_("Ok"), _("Yes")]: self.rc = 1 elif self.msgBox.clickedButton().text() in [ _("Cancel"), _("No") ]: self.rc = 0 else: if self.msgBox.clickedButton().text() in self.customButtons: self.rc = self.customButtons.index( self.msgBox.clickedButton().text()) if destroyAfterRun: self.dialog = None return self.rc
def step_dialog(parent, title, msg, det_msg=''): d = QMessageBox(parent) d.setWindowTitle(title) d.setText(msg) d.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) return d.exec_() & QMessageBox.Cancel
class MessageWindow: def __init__(self, title, text, type="ok", default=None, customButtons =None, customIcon=None, run=True, destroyAfterRun=True, detailed=False, longText=""): self.rc = None self.dialog = None self.msgBox = QMessageBox() self.doCustom = False self.customButtons = customButtons icon = None buttons = None if type == 'ok': buttons = QMessageBox.Ok icon = "question" elif type == 'error': icon = "error" buttons = QMessageBox.Ok elif type == 'warning': icon = "warning" buttons = QMessageBox.Ok elif type == 'okcancel': icon = "question" buttons = QMessageBox.Ok | QMessageBox.Cancel elif type == 'question': icon = "question" buttons = QMessageBox.Ok | QMessageBox.Cancel elif type == 'yesno': icon = "question" buttons = QMessageBox.Yes | QMessageBox.No elif type == 'custom': self.doCustom = True if customIcon: icon = customIcon else: icon = "question" text = "<qt>%s</qt>" % text.replace("\n", " ") self.msgBox.setText(text) if detailed: self.msgBox.setDetailedText(unicode(longText)) if self.doCustom: button = None for index, text in enumerate(self.customButtons): button = self.msgBox.addButton(text, QMessageBox.ActionRole) if default is not None and default == index: self.msgBox.setDefaultButton(button) else: self.msgBox.setStandardButtons(buttons) if default == "no": default = QMessageBox.No elif default == "yes": default = QMessageBox.Yes elif default == "ok": default = QMessageBox.Ok else: default = None self.msgBox.setDefaultButton(default) self.dialog = Dialog(_(title), self.msgBox, closeButton=False, isDialog=True, icon=icon) self.dialog.resize(QSize(0,0)) if run: self.run(destroyAfterRun) def run(self, destroyAfterRun=True): self.rc = self.dialog.exec_() if self.msgBox.clickedButton(): if not self.doCustom: if self.msgBox.clickedButton().text() in [_("Ok"), _("Yes")]: self.rc = 1 elif self.msgBox.clickedButton().text() in [_("Cancel"), _("No")]: self.rc = 0 else: if self.msgBox.clickedButton().text() in self.customButtons: self.rc = self.customButtons.index(self.msgBox.clickedButton().text()) if destroyAfterRun: self.dialog = None return self.rc
def update_table(self, bd_option, interp_option, anchor_index, bd_plot): # if there are no rows and columns in the model, # nothing can be updated if bd_plot: plt.close() elif ((not bd_plot) and len(self._horizontal_headers) > 5): msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText( "Your BD plot will contain more than 5 curves, do you really want to continue?" ) msg.setWindowTitle("Info") msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) result = msg.exec() if result == QMessageBox.Cancel: plt.close() bd_plot = True if self.rowCount(self) == 0 and self.columnCount(self) == 0: return # set the whole data matrix to zero first self._data = np.zeros( (len(self._vertical_headers), len(self._horizontal_headers))) # if we have passed the index of the column for the anchor select that one as anchor anchor = self._horizontal_headers[self._anchor_index] if isinstance(anchor_index, int) and anchor_index != -1: if (self._anchor_index != anchor_index) and not bd_plot: plt.clf() anchor = self._horizontal_headers[anchor_index] self._anchor_index = anchor_index # iterate over all rows (sequences) and columns (configurations) # of the table. Calculate one bd for each cell and store it in the # model. Emit in the very end the dataChanged signal row = 0 for seq in self._vertical_headers: # the AVG seq is actually not a sequence, so just skip it if (seq == 'AVG'): continue col = 0 for config in self._horizontal_headers: # for the anchor vs anchor measurement the bd is zero, # so just skip that case if config == anchor: col += 1 continue # determine the identifiers of the current cell identifiers_tmp = [seq, config] # if the anchor configuration is not available for the current seq continue if len([ x for x in self._plot_data_collection if '+'.join(x.identifiers).__eq__('+'.join( [identifiers_tmp[0], anchor])) ]) == 0: self._data[row, col] = np.nan col += 1 continue # get the rd values for curve c1 which is the anchor c1 = [ x for x in self._plot_data_collection if '+'.join(x.identifiers).__eq__('+'.join( [identifiers_tmp[0], anchor])) ][0].values c1 = sorted( list(set(c1)) ) # remove duplicates, this is just a workaround for the moment.... # if the configuration is not available for the current seq continue if len([ x for x in self._plot_data_collection if '+'.join( x.identifiers).__eq__('+'.join(identifiers_tmp)) ]) == 0: self._data[row, col] = np.nan col += 1 continue # get the rd values for curve c2 c2 = [ x for x in self._plot_data_collection if '+'.join( x.identifiers).__eq__('+'.join(identifiers_tmp)) ][0].values c2 = sorted(list(set(c2))) # if a simulation does not contain at least 4 rate points, # we do not want to calculate the bd if len(c1) < 4 or len(c2) < 4: self._data[row, col] = np.nan col += 1 continue # calculate the bd, actually this can be extended by some plots configs = [anchor, identifiers_tmp[1]] self._data[row, col] = bjontegaard(c1, c2, bd_option, interp_option, 'BD Plot ' + seq, configs, bd_plot) col += 1 row += 1 # calculate the AVG rate savings or delta psnr and round the output to something meaningful self._data[row, :] = np.mean( self._data[:-1, :][~np.isnan(self._data[:-1, :]).any(axis=1)], axis=0) self._data = np.around(self._data, decimals=2) self.dataChanged.emit(self.index(0, 0), self.index(row, col))
def _save_dialog(self, parent, title, msg, det_msg=''): d = QMessageBox(parent) d.setWindowTitle(title) d.setText(msg) d.setStandardButtons(QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel) return d.exec_()
def update(self, plot_data_collection, bd_option, interp_option, bd_plot): # reset the model in the first place and set data afterwards appropriately self.beginResetModel() self.reset_model() self.endResetModel() # there is no need to calculate a bd for just one curve if len(plot_data_collection) < 2: plt.close() return seq_set = set() config_set = set() indentifiers_list = [] for i in plot_data_collection: # there is no reason for calculating a bjontegaard, if we want to plot # serveral variables from the same sequence and config, so return in that case # otherwise append the identifiers to the list and go on if indentifiers_list.__contains__(i.identifiers): return indentifiers_list.append(i.identifiers) seq_set.add(i.identifiers[0]) config_set.add('+'.join(i.identifiers[1:])) seq_set = sorted(seq_set) config_set = sorted(config_set) if len(seq_set) > 1: plt.close() bd_plot = True # there is no need to calculate a bjontegaard delta, if only one configuration is loaded if len(config_set) < 2: plt.close() return elif len(config_set) > 5 and (not bd_plot): msg = QMessageBox() msg.setIcon(QMessageBox.Information) msg.setText( "Your BD plot will contain more than 5 curves, do you really want to continue?" ) msg.setWindowTitle("Info") msg.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) result = msg.exec() if result == QMessageBox.Cancel: plt.close() bd_plot = True self._horizontal_headers = list(config_set) self._vertical_headers = list(seq_set) self._vertical_headers.append('AVG') # insert as many columns as we need for the selected data self.beginInsertColumns(QModelIndex(), 0, len(config_set) - 1) self.insertColumns(0, len(config_set), QModelIndex()) self.endInsertColumns() # insert as many rows as we need for the selected data # and add one row for the average self.beginInsertRows(QModelIndex(), 0, len(seq_set)) self.insertRows(0, len(seq_set), QModelIndex()) self.endInsertRows() self._plot_data_collection = plot_data_collection self._data = np.zeros((len(seq_set) + 1, len(config_set))) if all(collection.label == ("kbps", "dB") for collection in plot_data_collection): self.update_table(bd_option, interp_option, 0, bd_plot) else: self.beginResetModel() self.reset_model() self.endResetModel() plt.close()