import tkinter as tk
import random

# 主窗口
root = tk.Tk()
root.title("🎲 随机点名抽签器")
root.geometry("500x450")
root.resizable(False, False)
root.configure(bg="#1F2937")

# 名单默认
name_list = [
    "张三","李四","王五","赵六",
    "陈七","刘八","周九","吴十"
]
running = False

# 大标题
title = tk.Label(root, text="随机点名抽签器", font=("微软雅黑", 24, "bold"), bg="#1F2937", fg="#FFD700")
title.pack(pady=20)

# 显示名字大屏
show_label = tk.Label(root, text="准备开始", font=("微软雅黑", 36, "bold"), bg="#1F2937", fg="#4ADE80")
show_label.pack(pady=30)

# 滚动刷新名字
def roll_name():
    if not running:
        return
    show_label.config(text=random.choice(name_list))
    root.after(80, roll_name)

# 开始抽签
def start_roll():
    global running
    if running:
        return
    running = True
    roll_name()
    show_label.config(fg="#4ADE80")

# 停止抽签
def stop_roll():
    global running
    running = False
    show_label.config(fg="#FF6B6B")

# 自定义名单输入框
tk.Label(root, text="自定义名单(用空格隔开)", font=("微软雅黑",12), bg="#1F2937", fg="white").pack()
entry = tk.Entry(root, font=("微软雅黑",14), width=40)
entry.pack(pady=10)

# 更新名单
def update_list():
    global name_list
    txt = entry.get().strip()
    if txt:
        name_list = txt.split()
        show_label.config(text="名单已更新")

# 按钮区
frame_btn = tk.Frame(root, bg="#1F2937")
frame_btn.pack(pady=15)

tk.Button(frame_btn, text="开始抽签", command=start_roll,
          font=("微软雅黑",14), bg="#22C55E", fg="white", width=10).grid(row=0,column=0,padx=8)

tk.Button(frame_btn, text="停止抽签", command=stop_roll,
          font=("微软雅黑",14), bg="#EF4444", fg="white", width=10).grid(row=0,column=1,padx=8)

tk.Button(root, text="更新自定义名单", command=update_list,
          font=("微软雅黑",12), bg="#3B82F6", fg="white").pack()

root.mainloop()