import tkinter as tk
import random

# 唐诗100首的简化示例
poems = [
    {
        "title": "静夜思",
        "author": "李白",
        "content": "床前明月光，\n疑是地上霜。\n举头望明月，\n低头思故乡。"
    },
    {
        "title": "春晓",
        "author": "孟浩然",
        "content": "春眠不觉晓，\n处处闻啼鸟。\n夜来风雨声，\n花落知多少。"
    },
    {
        "title": "望庐山瀑布",
        "author": "李白",
        "content": "日照香炉生紫烟，\n遥看瀑布挂前川。\n飞流直下三千尺，\n疑是银河落九天。"
    },
    {
        "title": "登鹳雀楼",
        "author": "王之涣",
        "content": "白日依山尽，\n苍苍鸥鹭飞。\n欲穷千里目，\n更上一层楼。"
    },
    # 这里可以添加更多的唐诗...
]

class PoetryApp:
    def __init__(self, root):
        self.root = root
        self.root.title("唐诗100首")

        self.title_label = tk.Label(root, text="", font=("Arial", 16, "bold"))
        self.title_label.pack(pady=10)

        self.author_label = tk.Label(root, text="", font=("Arial", 14))
        self.author_label.pack(pady=5)

        self.content_text = tk.Text(root, wrap=tk.WORD, width=40, height=10, font=("Arial", 12))
        self.content_text.pack(pady=10)

        self.next_button = tk.Button(root, text="下一首", command=self.show_random_poem, font=("Arial", 14))
        self.next_button.pack(pady=20)

        self.show_random_poem()

    def show_random_poem(self):
        poem = random.choice(poems)
        self.title_label.config(text=poem["title"])
        self.author_label.config(text=poem["author"])
        self.content_text.delete(1.0, tk.END)  # 清空文本框
        self.content_text.insert(tk.END, poem["content"])  # 插入新诗

if __name__ == "__main__":
    root = tk.Tk()
    app = PoetryApp(root)
    root.mainloop()