"""
启动器 - 选择启动配置界面或主程序
"""
import tkinter as tk
from tkinter import ttk
import subprocess
import sys

def start_config_gui():
    """启动配置界面"""
    subprocess.Popen([sys.executable, "gui_config.py"])

def start_preview():
    """启动预览窗口"""
    subprocess.Popen([sys.executable, "preview.py"])

def start_main_program():
    """启动主程序"""
    subprocess.Popen([sys.executable, "main.py"])

def create_launcher():
    """创建启动器界面"""
    root = tk.Tk()
    root.title("火炬之光自动化 - 启动器")
    root.geometry("400x300")
    root.resizable(False, False)
    
    # 标题
    title_frame = tk.Frame(root)
    title_frame.pack(fill=tk.X, pady=20)
    
    tk.Label(title_frame, text="火炬之光自动化脚本", font=('Arial', 16, 'bold')).pack()
    tk.Label(title_frame, text="请选择要启动的功能", font=('Arial', 10)).pack()
    
    # 按钮区域
    button_frame = tk.Frame(root)
    button_frame.pack(fill=tk.BOTH, expand=True, padx=40, pady=20)
    
    # 配置界面按钮
    config_btn = tk.Button(button_frame, text="⚙️ 配置管理", 
                          command=start_config_gui,
                          width=30, height=3, font=('Arial', 12))
    config_btn.pack(pady=10)
    
    # 预览窗口按钮
    preview_btn = tk.Button(button_frame, text="👁️ 采集卡预览", 
                           command=start_preview,
                           width=30, height=3, font=('Arial', 12))
    preview_btn.pack(pady=10)
    
    # 主程序按钮
    main_btn = tk.Button(button_frame, text="🚀 启动自动化", 
                         command=start_main_program,
                         width=30, height=3, font=('Arial', 12))
    main_btn.pack(pady=10)
    
    # 说明
    info_label = tk.Label(root, 
                         text="提示：首次使用请先点击"配置管理"设置参数",
                         font=('Arial', 9), 
                         fg='gray')
    info_label.pack(side=tk.BOTTOM, pady=10)
    
    root.mainloop()

if __name__ == "__main__":
    create_launcher()

