style: 统一界面中所有路径的斜杠分隔符格式

This commit is contained in:
HONOR
2026-09-16 11:33:22 +08:00
parent a350054271
commit 6a0040580e
+7 -6
View File
@@ -197,15 +197,16 @@ class BatchTableExtractorApp:
filetypes=[("Word 文档", "*.doc *.docx"), ("所有文件", "*.*")] filetypes=[("Word 文档", "*.doc *.docx"), ("所有文件", "*.*")]
) )
if path: if path:
path = os.path.normpath(path)
self.src_path_var.set(path) self.src_path_var.set(path)
if not self.out_dir_var.get().strip(): if not self.out_dir_var.get().strip():
base_dir = path if self.mode_var.get() == "dir" else os.path.dirname(path) base_dir = path if self.mode_var.get() == "dir" else os.path.dirname(path)
self.out_dir_var.set(os.path.join(base_dir, "convert")) self.out_dir_var.set(os.path.normpath(os.path.join(base_dir, "convert")))
def _browse_out(self): def _browse_out(self):
path = filedialog.askdirectory(title="选择输出目录") path = filedialog.askdirectory(title="选择输出目录")
if path: if path:
self.out_dir_var.set(path) self.out_dir_var.set(os.path.normpath(path))
def _on_drop_files(self, files): def _on_drop_files(self, files):
if not files: if not files:
@@ -231,15 +232,15 @@ class BatchTableExtractorApp:
if os.path.isdir(first_path): if os.path.isdir(first_path):
self.mode_var.set("dir") self.mode_var.set("dir")
self._on_mode_change() self._on_mode_change()
self.src_path_var.set(first_path) self.src_path_var.set(os.path.normpath(first_path))
if not self.out_dir_var.get().strip(): if not self.out_dir_var.get().strip():
self.out_dir_var.set(os.path.join(first_path, "convert")) self.out_dir_var.set(os.path.normpath(os.path.join(first_path, "convert")))
elif os.path.isfile(first_path): elif os.path.isfile(first_path):
self.mode_var.set("file") self.mode_var.set("file")
self._on_mode_change() self._on_mode_change()
self.src_path_var.set(first_path) self.src_path_var.set(os.path.normpath(first_path))
if not self.out_dir_var.get().strip(): if not self.out_dir_var.get().strip():
self.out_dir_var.set(os.path.join(os.path.dirname(first_path), "convert")) self.out_dir_var.set(os.path.normpath(os.path.join(os.path.dirname(first_path), "convert")))
if self.auto_extract_var.get(): if self.auto_extract_var.get():
self.root.after(100, self._start) self.root.after(100, self._start)