def get_stage(self, st_i): start_num = None info = [] check = True DS = None try: start_num = input_to_num(self.start_num) if self.name == "": info.append(["Empty_stage_name", st_i, ""]) check = False logger.warning("Empty stage name: {}".format(st_i)) if start_num < 0: info.append(["Negative_start_num", st_i, ""]) check = False logger.warning("Negative start num: {}".format(st_i)) if isinstance(start_num, float): info.append(["Float_start_num", st_i, ""]) check = False logger.warning("Float start num: {}".format(st_i)) except ValueError: info.append(["Incorrect_entered_value", st_i, "Stage"]) check = False logger.warning("Incorrect entered value stage {}".format(st_i)) except Exception as e: msg = traceback.format_exc() + "Last element: {1} No.{0}" logger.error(msg.format(st_i, "Stage")) emsg = ErrorMessage(message=msg.format(st_i, "Stage"), parent_w=self.parent_w) emsg.exec_() raise SystemExit(1) if check: DS = DiseaseStage(self.name, start_num) return [DS, check, info]
def __init__(self, group_c, number, parent_w): try: super(GroupWidget, self).__init__() self.setupUi(self) self.content = group_c self.number = number self.parent_w = parent_w self.lang_parser = self.parent_w.parent_w.lang_parser self.Group_name_edit.setText(self.content.name) # добавить стадии в комбобокс for stage in self.parent_w.stages: self.Group_stage_box.addItem(stage) # добавить стадии группы в список for stage in self.content.stage_lst: self.Group_stage_lst.addItem(stage) self.Del_group_btn.clicked.connect(self.del_group) self.Group_stage_add_btn.clicked.connect(self.add_stage) self.Group_stage_del_btn.clicked.connect(self.del_stage) self.set_text() logger.debug("Init GroupWidget") except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w.parent_w) emsg.exec_() raise SystemExit(1)
def get_ow_flow(self, owf_i): info = [] check = True factor = "" Owfl = None try: if self.dynamic: if self.dfactor == "": info.append(["Empty_owflow_dfactor", owf_i, ""]) logger.warning("Empty owflow dfactor {}".format(owf_i)) check = False elif self.dfactor in [ factor.name for factor in self.list_factor ]: i = 0 while self.list_factor[i].name != self.dfactor: i += 1 factor, check_add, info_add = self.list_factor[ i].get_factor() if not check_add: info += info_add check = False else: info.append( ["Not_exist_dfactor_owflow", owf_i, self.dfactor]) logger.warning("Not exist dfactor owflow {}".format(owf_i)) check = False else: if self.sfactor == "": info.append(["Empty_owflow_sfactor", owf_i, ""]) logger.warning("Empty owflow sfactor {}".format(owf_i)) check = False else: try: factor = Factor(input_to_num(self.sfactor)) if factor.factor < 0: info.append(["Negative_owflow_sfactor", owf_i, ""]) logger.warning( "Negative owflow sfactor {}".format(owf_i)) check = False except ValueError: info.append(["Incorrect_owflow_sfactor", owf_i, ""]) logger.warning( "Incorrect owflow sfactor {}".format(owf_i)) check = False except Exception as e: msg = traceback.format_exc() + "Last element: {0} No.{1}" logger.error(msg.format("OW_flow", owf_i)) emsg = ErrorMessage(message=msg.format("OW_flow", owf_i), parent_w=self.parent_w) emsg.exec_() raise SystemExit(1) if check: Owfl = ExternalFlow(self.stage, factor, self.direction, self.relativity) return [Owfl, check, info]
def __init__(self, result_c, number, parent_w): try: super(ResultWidget, self).__init__() self.setupUi(self) self.content = result_c self.parent_w = parent_w self.number = number self.suffix = "" # настройка галочки отображения self.Result_show_cbox.stateChanged.connect(self.change_show) self.Result_show_cbox.setChecked(self.content.show) # настройка кнопок #self.Del_result_btn.setIcon(QtGui.QIcon("icon/delete_icon_2.png")) self.Del_result_btn.clicked.connect(self.delete) self.Result_info_btn.clicked.connect(self.show_info) self.Result_set_group_btn.clicked.connect(self.set_group) self.Result_group_res_btn.clicked.connect(self.add_result_group) self.set_text() logger.debug("Init ResultWidget") except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w) emsg.exec_() raise SystemExit(1)
def __init__(self, settings, user_settings, parent_w): try: self.new_settings = Settings(settings) self.new_user_settings = UserSettings(parent_w.deep_settings, user_settings) self.deep_settings = parent_w.deep_settings super(SettingsDialog, self).__init__() self.setupUi(self) self.parent_w = parent_w self.lang_list = [] self.fill_boxes() self.set_text() self.update_btn_box() self.Set_default_btn.clicked.connect(self.set_default) self.setWindowIcon( QtGui.QIcon(self.parent_w.deep_settings.window_icon_filename)) logger.debug("Init SettingsDialog") except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w) emsg.exec_() raise SystemExit(1)
def add_ind_stage(self): try: if self.Flow_istage_name_box.currentText( ) != "" and self.Flow_istage_infect_edit.text() != "": if self.Flow_istage_name_box.currentText( ) in self.content.dic_ind: for i in range(self.Flow_istage_lst.count()): if self.Flow_istage_lst.item(i).text( ) == "{0}: {1}".format( self.Flow_istage_name_box.currentText(), self.content.dic_ind[ self.Flow_istage_name_box.currentText()]): self.Flow_istage_lst.item(i).setText( "{0}: {1}".format( self.Flow_istage_name_box.currentText(), self.Flow_istage_infect_edit.text())) else: self.Flow_istage_lst.addItem("{0}: {1}".format( self.Flow_istage_name_box.currentText(), self.Flow_istage_infect_edit.text())) self.content.dic_ind[self.Flow_istage_name_box.currentText( )] = self.Flow_istage_infect_edit.text() except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w) emsg.exec_() raise SystemExit(1)
def change_induction(self): try: if self.Flow_induction_cbox.isChecked(): self.Flow_istage_lbl.setEnabled(True) self.Flow_istage_name_lbl.setEnabled(True) self.Flow_istage_name_box.setEnabled(True) self.Flow_istage_infect_lbl.setEnabled(True) self.Flow_istage_infect_edit.setEnabled(True) self.Flow_add_istage_btn.setEnabled(True) self.Flow_istage_lst.setEnabled(True) self.Flow_del_istage_btn.setEnabled(True) else: self.Flow_istage_lbl.setEnabled(False) self.Flow_istage_name_lbl.setEnabled(False) self.Flow_istage_name_box.setEnabled(False) self.Flow_istage_infect_lbl.setEnabled(False) self.Flow_istage_infect_edit.setEnabled(False) self.Flow_add_istage_btn.setEnabled(False) self.Flow_istage_lst.setEnabled(False) self.Flow_del_istage_btn.setEnabled(False) except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w) emsg.exec_() raise SystemExit(1)
def set_reset(self): try: section = self.parent_w.user_settings.language.upper() question = self.parent_w.lang_parser.get( section, "Reset_question_lbl", fallback="Reset_question_lbl") title = self.parent_w.lang_parser.get(section, "Reset_title", fallback="Reset_title") yes_text = self.parent_w.lang_parser.get(section, "Yes", fallback="Yes") no_text = self.parent_w.lang_parser.get(section, "No", fallback="No") question = QuestionDialog(self.parent_w, question, title, yes_text, no_text) question.exec_() if question.answer == 1: self.new_settings = Settings() self.new_user_settings = UserSettings(self.deep_settings) self.fill_boxes() self.apply() except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w) emsg.exec_() raise SystemExit(1)
def __init__(self, parent_w, question, title, yes_text, no_text): try: super(QuestionDialog, self).__init__() self.question_layout = QtWidgets.QVBoxLayout(self) self.parent_w = parent_w self.answer = 0 self.setWindowTitle(title) self.question_lbl = QtWidgets.QLabel(question) self.question_layout.addWidget(self.question_lbl) self.question_layout.addWidget(self.question_lbl) self.btn_box = QtWidgets.QDialogButtonBox(self) self.question_layout.addWidget(self.btn_box) yes_btn = QtWidgets.QPushButton(yes_text) no_btn = QtWidgets.QPushButton(no_text) self.btn_box.addButton(yes_btn, QtWidgets.QDialogButtonBox.YesRole) self.btn_box.addButton(no_btn, QtWidgets.QDialogButtonBox.ResetRole) self.btn_box.setCenterButtons(True) yes_btn.clicked.connect(self.yes) no_btn.clicked.connect(self.no) logger.debug("Init QuestionDialog") except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w) emsg.exec_() raise SystemExit(1)
def delete(self): try: self.parent_w.delete_flow(self.number) except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w) emsg.exec_() raise SystemExit(1)
def show_info(self): try: dialog = ResultInfoDialog(self.parent_w, self.content.info) dialog.exec_() except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w) emsg.exec_() raise SystemExit(1)
def change_show(self): try: self.content.show = self.Result_show_cbox.isChecked() self.parent_w.update_show_result() except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w) emsg.exec_() raise SystemExit(1)
def set_default(self): try: self.new_settings = Settings() self.fill_boxes() except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w) emsg.exec_() raise SystemExit(1)
def apply(self): try: self.update_info() self.close() except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w) emsg.exec_() raise SystemExit(1)
def cancel(self): try: self.groups = list(self.old_groups) self.close() except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w) emsg.exec_() raise SystemExit(1)
def apply(self): try: self.content = self.Description_edit.toPlainText() self.close() except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w) emsg.exec_() raise SystemExit(1)
def clear_step_value(self): try: self.Dfactor_value_lst.clear() self.content.dic_values = {} except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w) emsg.exec_() raise SystemExit(1)
def add_group(self): try: self.update_info() self.groups.append(GroupContent(next(self.name_generator))) self.update_groups() except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w) emsg.exec_() raise SystemExit(1)
def del_group(self, group_num): try: self.update_info() self.groups.pop(group_num) self.update_groups() except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w) emsg.exec_() raise SystemExit(1)
def set_group(self): try: dialog = GroupDialog(self.content.result_dic, self.content.groups, self.parent_w) dialog.exec_() self.content.groups = list(dialog.groups) except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w) emsg.exec_() raise SystemExit(1)
def load_model(self): try: self.parent_w.open_file_model() if self.parent_w.model_open: self.parent_w.set_all_enabled(True) self.close() except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w) emsg.exec_() raise SystemExit(1)
def select_file(self): try: section = self.parent_w.user_settings.language.upper() title = self.parent_w.lang_parser.get( section, "Open_dfactor_title", fallback="Open_dfactor_title") self.Dfactor_file_name_edit.setText( QtWidgets.QFileDialog.getOpenFileName(self.parent_w, title)[0]) except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w) emsg.exec_() raise SystemExit(1)
def del_stage(self): try: if self.Group_stage_lst.currentItem() is not None: stage = self.Group_stage_lst.currentItem().text() self.content.stage_lst.pop(self.content.stage_lst.index(stage)) self.Group_stage_lst.takeItem( self.Group_stage_lst.currentRow()) except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w.parent_w) emsg.exec_() raise SystemExit(1)
def add_stage(self): try: if self.Group_stage_box.currentText() != "": self.Group_stage_lst.addItem( self.Group_stage_box.currentText()) self.content.stage_lst.append( self.Group_stage_box.currentText()) except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w.parent_w) emsg.exec_() raise SystemExit(1)
def del_ind_stage(self): try: if self.Flow_istage_lst.currentItem() is not None: ind_stage_name, _ = self.Flow_istage_lst.currentItem().text( ).split(":") del self.content.dic_ind[ind_stage_name] self.Flow_istage_lst.takeItem( self.Flow_istage_lst.currentRow()) except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w) emsg.exec_() raise SystemExit(1)
def apply(self): try: self.new_user_settings.file_delimiter = self.Set_delimiter_edit.text( ) self.new_user_settings.max_num_graphs = self.Set_max_graphs_edit.text( ) self.new_user_settings.dfactor_file_head = self.Set_df_file_head_cbox.isChecked( ) self.new_user_settings.language = self.Set_language_box.currentText( ) self.new_settings.divided_n = self.Set_divided_n_cbox.isChecked() self.new_settings.braking_dist = self.Set_breaking_dist_edit.text() self.new_settings.threshold = self.Set_threshold_edit.text() self.new_settings.check_period = self.Set_check_period_edit.text() self.new_settings.max_step = self.Set_max_step_edit.text() check_s, info_s = self.new_settings.check_settings() check_us, info_us = self.new_user_settings.check_settings() if check_s and check_us: self.new_user_settings.write_user_settings() self.parent_w.settings = Settings(self.new_settings) self.parent_w.user_settings = UserSettings( self.parent_w.deep_settings, self.new_user_settings) self.parent_w.full_update() self.set_text() self.update_btn_box() self.fill_boxes() return True else: message = "" for i in info_s: message += self.parent_w.get_message_text(i) + "\n" for i in info_us: message += self.parent_w.get_message_text(i) + "\n" title = "Settings_error" title = self.parent_w.lang_parser.get( self.parent_w.user_settings.language.upper(), title, fallback=title) msg_window = Message(message, title, self.parent_w) msg_window.exec_() return False except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w) emsg.exec_() raise SystemExit(1)
def apply(self): try: self.parent_w.take_default() name = self.New_name_edit.text() location = self.New_location_edit.text() self.parent_w.create_new_model(name, location) self.parent_w.model_open = True self.parent_w.set_all_enabled(True) self.close() except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w) emsg.exec_() raise SystemExit(1)
def add_result_group(self): try: if self.content.groups: self.suffix = self.get_suffix() self.content.add_group_info(self.suffix) new_filename = self.content.file_result[:-4] + self.suffix result_dic = self.content.create_group_result() self.parent_w.add_result(self.content.f_path + new_filename, result_dic=result_dic, new=True) except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w) emsg.exec_() raise SystemExit(1)
def select_location(self): try: section = self.parent_w.user_settings.language.upper() location = QtWidgets.QFileDialog.getExistingDirectory( self, self.parent_w.lang_parser.get(section, "New_location_title", fallback="New_location_title")) if location != "": self.New_location_edit.setText(location + "/") except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w) emsg.exec_() raise SystemExit(1)
def change_factor(self): try: if self.Flow_dfactor_cbox.isChecked(): self.Flow_dfactor_name_lbl.setEnabled(True) self.Flow_dfactor_name_box.setEnabled(True) self.Flow_sfactor_value_lbl.setEnabled(False) self.Flow_sfactor_value_edit.setEnabled(False) else: self.Flow_dfactor_name_lbl.setEnabled(False) self.Flow_dfactor_name_box.setEnabled(False) self.Flow_sfactor_value_lbl.setEnabled(True) self.Flow_sfactor_value_edit.setEnabled(True) except Exception as e: msg = traceback.format_exc() logger.error("Unknown error", exc_info=True) emsg = ErrorMessage(message=msg, parent_w=self.parent_w) emsg.exec_() raise SystemExit(1)