def run(self): for self.index in range(len(self.list)): if self.index < len(self.list) and not self.stop: name = self.list[self.index] self.format.m_staticText_now.SetLabel("当前:%s" % self.names[name]) self.format.m_gauge_now.SetValue(0) function.restore_tool(name, self.names, self.mesh_list_path_dir, self.tex_list_path_dir, self.save_path) self.format.m_gauge_now.SetValue(100) val_percent = str(round(100 * (self.index / len(self.list)), 2)) val = function.re_int(100 * (self.index / len(self.list))) self.format.m_staticText_all.SetLabel("总进度:%s %%" % val_percent) self.format.m_gauge_all.SetValue(val) self.index += 1 self.format.m_staticText_all.SetLabel("总进度:%s %%" % '100') self.format.start = False if self.format.m_checkBox_autoopen.GetValue(): os.system(r"start %s" % self.save_path)
def copy_file(self, event): self.file_save = wx.DirDialog(self, "保存", os.getcwd(), style=wx.DD_DIR_MUST_EXIST | wx.DD_CHANGE_DIR | wx.DD_NEW_DIR_BUTTON | wx.DD_DEFAULT_STYLE) if self.file_save.ShowModal() == wx.ID_OK: path = self.file_save.GetPath() num = 0 self.m_gauge_all.SetValue(0) for name in self.disable_restore_list: num += 1 self.m_gauge_now.SetValue(0) shutil.copyfile(self.tex_list_path_dir[name], f'{path}\\{self.names[name]}.png') self.m_gauge_now.SetValue(100) self.m_gauge_all.SetValue(function.re_int(100 * (num / len(self.disable_restore_list)))) if self.m_checkBox_autoopen.GetValue(): os.system(self.save_path)
def load_mesh_fold(self, event): self.dir_dialog = wx.DirDialog(self, "打开", os.getcwd(), style=wx.DD_NEW_DIR_BUTTON | wx.DD_CHANGE_DIR | wx.DD_DEFAULT_STYLE | wx.DD_DIR_MUST_EXIST) if self.dir_dialog.ShowModal() == wx.ID_OK: paths = self.dir_dialog.GetPath() self.m_staticText_mesh_load.SetLabel("开始") self.m_gauge_mesh_load.SetValue(0) paths = function.all_file_path(paths)[1] self.m_gauge_mesh_load.SetValue(25) num = 0 for path in paths.keys(): if paths[path].split('.')[-1] == 'obj' or paths[path].split('.')[-1] == "OBJ": path_old = path path = path.split('.')[0].split('-') if path[-2] == 'ui': path = path[0] + "-" + path[1] else: path = path[0] if path not in self.mesh_name: self.mesh_list_path_dir[path] = paths[path_old] self.mesh_name.append(path) try: self.mesh_name_cn.append(f"{num}){self.names[path]}——{path}") self._searched_mesh.append(f"{self.names[path]}{path}") except KeyError: self.mesh_name_cn.append(f"{num}){path}——{path}") self._searched_mesh.append(f"{path}") num += 1 self.m_gauge_mesh_load.SetValue(25 + function.re_int(75 * (num / len(paths.keys())))) self.m_staticText_mesh_load.SetLabel("完成") self.m_listBox_mesh.Set(self.mesh_name_cn) if self.able_export(): self.m_menuItem_all.Enable(True) else: self.m_menuItem_all.Enable(False) if len(self.disable_restore_list) >= 1: self.m_menuItem_copy_only.Enable(True) else: self.m_menuItem_copy_only.Enable(False)
def load_Mesh(self, event): self.file_dialog = wx.FileDialog(self, "打开", os.getcwd(), wildcard="*.OBJ", style=wx.FD_MULTIPLE) if self.file_dialog.ShowModal() == wx.ID_OK: self.m_staticText_mesh_load.SetLabel("开始") self.m_gauge_mesh_load.SetValue(0) paths = self.file_dialog.GetPaths() if not len(paths) == 0: num = 0 for path in paths: num += 1 name = path.split('\\')[-1].split('.')[0].split('-') if name[-2] == 'ui': name = name[0] + "-" + name[1] else: name = name[0] if name not in self.mesh_name: self.mesh_list_path_dir[name] = path self.mesh_name.append(name) try: self.mesh_name_cn.append(f"{num}){self.names[name]}——{name}") self._searched_mesh.append(f"{self.names[name]}{name}") except KeyError: self.mesh_name_cn.append(f"{num}){name}——{name}") self._searched_mesh.append(f"{name}") self.m_gauge_tex_load.SetValue(function.re_int(100 * (num / len(paths)))) self.m_staticText_mesh_load.SetLabel("完成") self.m_listBox_mesh.Set(self.mesh_name_cn) if self.able_export(): self.m_menuItem_all.Enable(True) else: self.m_menuItem_all.Enable(False) if len(self.disable_restore_list) >= 1: self.m_menuItem_copy_only.Enable(True) else: self.m_menuItem_copy_only.Enable(False)
def open_add_name(self, event): index = self.m_listBox5.GetSelection() value = self.need_add[index] if value in self.names.keys(): value_cn = self.names[value] else: value_cn = '' writer = Writer(self, value, value_cn) bool_er = writer.ShowModal() if bool_er == 0: name = writer.GetValue() if name != '': self.finish_num += 1 elif value in self.names.keys() and name == '': self.finish_num -= 1 self.names[value] = name self.need_add_show[index] = "%s:%s" % (self.need_add[index], name) self.m_listBox5.Clear() self.m_listBox5.Set(self.need_add_show) scale = function.re_int(100 * (self.finish_num / len(self.need_add))) self.m_gauge5.SetValue(scale)