Files
Pro_llm_correct/main.py
2025-09-05 00:42:34 +08:00

37 lines
1.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import tkinter as tk
from app_ui import MainApp
from config_manager import ConfigManager
from api_services import ApiService
import sys
import os
def get_config_path():
"""
获取配置文件的合适路径。
在开发环境使用当前目录在打包环境使用exe所在目录。
"""
try:
# 检查是否在PyInstaller打包环境中
sys._MEIPASS
# 如果是打包环境使用exe文件所在目录
exe_dir = os.path.dirname(sys.executable)
return os.path.join(exe_dir, "config.json")
except Exception:
# 开发环境,使用当前目录
return "config.json"
if __name__ == "__main__":
# 1. 初始化核心服务
# 使用合适的配置文件路径
config_path = get_config_path()
config_manager = ConfigManager(config_path)
# 2. 创建Tkinter主窗口
root = tk.Tk()
# 3. 实例化主应用服务将在MainApp内部创建
app = MainApp(root, config_manager)
# 4. 启动Tkinter事件循环
root.mainloop()