初始化
This commit is contained in:
79
aprx_batch_gui.py
Normal file
79
aprx_batch_gui.py
Normal file
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
ArcGIS Pro批量处理工具 - GUI应用程序入口点
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import traceback
|
||||
|
||||
def main():
|
||||
"""主函数,启动GUI应用程序"""
|
||||
try:
|
||||
from PyQt6.QtWidgets import QApplication
|
||||
print("PyQt6导入成功")
|
||||
|
||||
# 添加项目路径到sys.path
|
||||
project_root = os.path.dirname(os.path.abspath(__file__))
|
||||
if project_root not in sys.path:
|
||||
sys.path.insert(0, project_root)
|
||||
print(f"添加项目路径到sys.path: {project_root}")
|
||||
|
||||
# 使用重构版的MainWindow
|
||||
from tools.ui.main_window import MainWindow
|
||||
print("MainWindow导入成功")
|
||||
|
||||
# 查找并设置ArcGIS Pro的Python环境
|
||||
try:
|
||||
# 常见的ArcGIS Pro Python路径
|
||||
arcgis_python_paths = [
|
||||
r"C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe",
|
||||
r"C:\Program Files\ArcGIS\Pro\bin\Python\python.exe"
|
||||
]
|
||||
|
||||
# 检查环境变量
|
||||
if 'ARCGISPRO_PYTHON' in os.environ:
|
||||
arcgis_python_paths.insert(0, os.environ['ARCGISPRO_PYTHON'])
|
||||
|
||||
# 尝试每个可能的路径
|
||||
for path in arcgis_python_paths:
|
||||
if os.path.exists(path):
|
||||
os.environ['ARCGISPRO_PYTHON'] = path
|
||||
print(f"设置ArcGIS Pro Python环境: {path}")
|
||||
break
|
||||
except Exception as e:
|
||||
print(f"设置Python环境失败: {str(e)}")
|
||||
|
||||
# 验证脚本目录
|
||||
core_script_dir = os.path.join(project_root, 'tools', 'core')
|
||||
if os.path.exists(core_script_dir):
|
||||
print(f"核心脚本目录存在: {core_script_dir}")
|
||||
script_files = [f for f in os.listdir(core_script_dir) if f.endswith('.py')]
|
||||
print(f"发现脚本文件: {', '.join(script_files)}")
|
||||
else:
|
||||
print(f"警告: 核心脚本目录不存在: {core_script_dir}")
|
||||
# 尝试创建核心脚本目录
|
||||
os.makedirs(core_script_dir, exist_ok=True)
|
||||
print(f"已创建核心脚本目录: {core_script_dir}")
|
||||
|
||||
# 启动GUI
|
||||
app = QApplication(sys.argv)
|
||||
# 设置应用程序样式
|
||||
# app.setStyle("Fusion")
|
||||
window = MainWindow()
|
||||
print("MainWindow实例创建成功")
|
||||
|
||||
window.show()
|
||||
print("窗口显示成功")
|
||||
|
||||
sys.exit(app.exec())
|
||||
except Exception as e:
|
||||
print(f"错误: {e}")
|
||||
print("详细错误信息:")
|
||||
traceback.print_exc()
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user