def get_warning(self): """获取警告信息""" warn = {} for key, message_set in self._warn.items(): warn_str = ",".join([str(i) for i in message_set]) warn[key] = warn_str Message.debug(f"运行时数据获取警告数据:{warn}") return warn
def reset_command(): """将添加了前后功能处理的函数添加到目录中""" RunTimeData.reset() Interface.functional_area_clean() _description(description) RunTimeData.set_components(components) for component in components: component.show() _run(run_func) Message.info(f"选择功能: {name}")
def _select_dir(self): """选择文件夹""" select_dir_path = filedialog.askdirectory( title=f"选择 {self._button_text} 对应文件夹") if select_dir_path: Message.info("选择文件夹:" + select_dir_path) self._value = select_dir_path self._label_str.set(select_dir_path) else: Message.warning("未选择文件夹")
def _select_file(self): """选择指定格式文件""" select_file_path = filedialog.askopenfilename( title=f'选择 {self._button_text} 文件', filetypes=_file_types(self._file_types)) if select_file_path: Message.info("选择文件:" + select_file_path) self._value = select_file_path self._label_str.set(select_file_path) else: Message.warning("未选择文件")
def _select_files(self): """选择指定格式文件""" select_file_paths = filedialog.askopenfilenames( title=f'选择 {self._button_text} 对应的多个文件', filetypes=_file_types(self._file_types)) if select_file_paths: self._value = select_file_paths self._label_str.set( json.dumps(select_file_paths, ensure_ascii=False)) Message.info("选择的多个文件为:") for file_path in select_file_paths: Message.info(file_path) else: Message.warning("未选择文件")
def reset(cls): """重置数据""" cls._data = {} cls._warn = {} cls._components = [] Message.debug('运行时数据重置')
def add_warning(cls, key, message): """程序运行中添加警告信息, key为标识, message添加到key对应的set中""" if key not in cls._warn: cls._warn[key] = set() cls._warn[key].add(str(message)) Message.debug(f"运行时数据添加警告信息:{key},{message}")
def reset_command(): """添加运行程序的头尾标识,并将异常信息添加到程序中""" try: Message.success("开始运行") start_time = time.time() values = RunTimeData.get_run_values() Message.debug(f"运行程序使用的值列表:{values}") command(*values) # 查看警告信息,如果有警告信息,就显示出来 warn = RunTimeData.get_warning() if warn: for key, message in warn.items(): key_message = f"{key}:{message}" Message.warning(key_message) Message.error("以上为警告信息") end_time = time.time() Message.success("成功结束, 运行时间: {:.4f} 秒".format(end_time - start_time)) except: Message.error("错误详细信息:{}".format(traceback.format_exc())) Message.error("程序运行出现错误")