refactor: path

This commit is contained in:
moesnow 2023-09-26 21:31:56 +08:00
parent d817333933
commit 0f84378967
No known key found for this signature in database
GPG Key ID: 90F1F58F79732047
2 changed files with 2 additions and 19 deletions

11
app.py
View File

@ -1,15 +1,6 @@
import os
import sys
if getattr(sys, 'frozen', False): # 检查是否是PyInstaller打包的可执行文件
# 获取可执行文件所在目录并设置为工作目录
app_dir = os.path.dirname(sys.executable)
else:
# 获取脚本所在目录并设置为工作目录
app_dir = os.path.dirname(os.path.abspath(__file__))
os.chdir(app_dir) # 修改工作目录
os.chdir(os.path.dirname(sys.executable) if getattr(sys, 'frozen', False) else os.path.dirname(os.path.abspath(__file__)))
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication

10
main.py
View File

@ -1,14 +1,6 @@
import os
import sys
if getattr(sys, 'frozen', False): # 检查是否是PyInstaller打包的可执行文件
# 获取可执行文件所在目录并设置为工作目录
app_dir = os.path.dirname(sys.executable)
else:
# 获取脚本所在目录并设置为工作目录
app_dir = os.path.dirname(os.path.abspath(__file__))
os.chdir(app_dir) # 修改工作目录
os.chdir(os.path.dirname(sys.executable) if getattr(sys, 'frozen', False) else os.path.dirname(os.path.abspath(__file__)))
from managers.notify_manager import notify
from managers.logger_manager import logger