Skip to content

Commit 97d47ef

Browse files
committed
Use open_dir_in_explorer()
1 parent 8adcd2f commit 97d47ef

2 files changed

Lines changed: 5 additions & 9 deletions

File tree

src/py2exe_gui/Utilities/platform_specifc_funcs.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
"""
88

99
import subprocess
10+
from pathlib import Path
11+
from typing import Union
1012

1113
from ..Constants import PLATFORM, RUNTIME_INFO
1214

1315

14-
def open_dir_in_explorer(dir_path: str) -> None:
16+
def open_dir_in_explorer(dir_path: Union[str, Path]) -> None:
1517
"""
1618
在操作系统文件资源管理器中打开指定目录 \n
1719
:param dir_path: 待打开的目录路径

src/py2exe_gui/__main__.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# For details: https://github.com/muziing/Py2exe-GUI/blob/main/README.md#license
33

44
import sys
5-
from subprocess import call as subprocess_call
65

76
from PySide6.QtCore import Slot
87
from PySide6.QtGui import QCloseEvent
@@ -11,6 +10,7 @@
1110
from .Constants import PLATFORM, RUNTIME_INFO # noqa
1211
from .Core import Packaging, PackagingTask # noqa
1312
from .Resources import COMPILED_RESOURCES # noqa
13+
from .Utilities import open_dir_in_explorer # noqa
1414
from .Widgets import MainWindow, SubProcessDlg # noqa
1515

1616

@@ -83,13 +83,7 @@ def handle_multifunction() -> None:
8383
self.subprocess_dlg.close()
8484
elif btn_text == "打开输出位置":
8585
dist_path = self.packaging_task.script_path.parent / "dist"
86-
if PLATFORM.windows == RUNTIME_INFO.platform:
87-
from os import startfile as os_startfile # fmt: skip
88-
os_startfile(dist_path) # noqa
89-
elif PLATFORM.linux == RUNTIME_INFO.platform:
90-
subprocess_call(["xdg-open", dist_path])
91-
elif PLATFORM.macos == RUNTIME_INFO.platform:
92-
subprocess_call(["open", dist_path])
86+
open_dir_in_explorer(dist_path)
9387
elif btn_text == "关闭":
9488
self.subprocess_dlg.close()
9589

0 commit comments

Comments
 (0)