# -*- coding: utf-8 -*-
import tkinter as tk
from tkinter import ttk, Label, Frame, Button
import sys
import os

# 解决路径问题（适配所有Python编辑器，无需手动配置）
def get_resource_path(relative_path):
    try:
        base_path = sys._MEIPASS
    except Exception:
        base_path = sys.path[0]
    return os.path.join(base_path, relative_path)

# ---------------------- 主窗口设置（史无前例积极向上风格）----------------------
root = tk.Tk()
root.title("🇨🇳 红色经典 · 中国历史名言 ")
root.geometry("1000x800")  # 适中尺寸，适合展示
root.resizable(False, False)  # 固定窗口，避免错乱
root.configure(bg="#FFFAFA")  # 浅红暖底，积极明亮，贴合红色主题

# 顶部红色标题栏（醒目大气，正能量拉满）
top_frame = Frame(root, bg="#DC143C", height=120)
top_frame.pack(fill="x", padx=20, pady=15)

# 标题文字（加粗醒目，适配五年级审美，贴合红色主题）
title_label = Label(
    top_frame,
    text="✨ 中国历史名言介绍 ✨\n传承经典 · 励志成长",
    font=("微软雅黑", 26, "bold"),
    bg="#DC143C",
    fg="white",
    justify=tk.CENTER
)
title_label.place(relx=0.5, rely=0.5, anchor="center")

# ---------------------- 中间名言展示区（五年级易懂，红色主题）----------------------
middle_frame = Frame(root, bg="white", relief=tk.RAISED, bd=2)
middle_frame.pack(fill="both", expand=True, padx=30, pady=10)

# 名言数据（精选适合五年级的红色、励志历史名言，易懂好记，积极向上）
quotes = [
    {
        "quote": "天下兴亡，匹夫有责",
        "author": "顾炎武（明末清初思想家）",
        "meaning": "国家的兴盛和灭亡，每一个普通人都有责任。告诉我们要热爱祖国，主动承担起守护国家的责任，做爱国的好少年。"
    },
    {
        "quote": "少年强则国强",
        "author": "梁启超（近代思想家）",
        "meaning": "少年一代如果强大、有志向，国家就会变得强大。激励我们从小努力学习、锻炼身体，长大后为祖国的发展贡献力量。"
    },
    {
        "quote": "人生自古谁无死？留取丹心照汗青",
        "author": "文天祥（南宋民族英雄）",
        "meaning": "人生在世，谁都会有死亡的一天，但要留下一颗忠诚爱国的心，永远被历史铭记。体现了古人宁死不屈的爱国气节。"
    },
    {
        "quote": "先天下之忧而忧，后天下之乐而乐",
        "author": "范仲淹（北宋文学家）",
        "meaning": "在天下人忧愁之前先忧愁，在天下人快乐之后才快乐。告诉我们要心怀家国，有奉献精神，多为他人、为国家着想。"
    },
    {
        "quote": "捐躯赴国难，视死忽如归",
        "author": "曹植（三国时期文学家）",
        "meaning": "为了国家的危难而献身，把死亡看得像回家一样平常。赞美了爱国志士勇敢无畏、为国牺牲的崇高精神。"
    }
]

# 当前名言索引（用于切换功能）
current_index = 0

# 名言展示标签（醒目、美观，适配五年级阅读）
quote_label = Label(
    middle_frame,
    text=quotes[current_index]["quote"],
    font=("微软雅黑", 28, "bold"),
    bg="white",
    fg="#DC143C",
    justify=tk.CENTER,
    wraplength=800
)
quote_label.pack(pady=(40, 20), padx=20)

# 作者标签
author_label = Label(
    middle_frame,
    text=f"—— {quotes[current_index]['author']}",
    font=("微软雅黑", 18),
    bg="white",
    fg="#666666",
    justify=tk.CENTER
)
author_label.pack(pady=(0, 30))

# 含义解释标签（通俗易懂，贴合五年级认知）
meaning_label = Label(
    middle_frame,
    text=f"含义：{quotes[current_index]['meaning']}",
    font=("微软雅黑", 16),
    bg="white",
    fg="#333333",
    justify=tk.LEFT,
    wraplength=800,
    padx=40
)
meaning_label.pack(pady=(0, 40))

# 切换名言功能（上一句、下一句）
def prev_quote():
    global current_index
    current_index = (current_index - 1) % len(quotes)
    update_quote()

def next_quote():
    global current_index
    current_index = (current_index + 1) % len(quotes)
    update_quote()

def update_quote():
    quote_label.config(text=quotes[current_index]["quote"])
    author_label.config(text=f"—— {quotes[current_index]['author']}")
    meaning_label.config(text=f"含义：{quotes[current_index]['meaning']}")

# 切换按钮（红色主题，美观易操作）
btn_frame = Frame(middle_frame, bg="white")
btn_frame.pack(pady=20)

prev_btn = Button(
    btn_frame,
    text="上一句",
    font=("微软雅黑", 16, "bold"),
    bg="#DC143C",
    fg="white",
    bd=0,
    padx=30,
    pady=10,
    command=prev_quote
)
prev_btn.pack(side=tk.LEFT, padx=20)

next_btn = Button(
    btn_frame,
    text="下一句",
    font=("微软雅黑", 16, "bold"),
    bg="#DC143C",
    fg="white",
    bd=0,
    padx=30,
    pady=10,
    command=next_quote
)
next_btn.pack(side=tk.RIGHT, padx=20)

# ---------------------- 功能介绍区（清晰易懂，适配五年级）----------------------
func_frame = Frame(root, bg="#FFFAFA", relief=tk.RAISED, bd=1)
func_frame.pack(fill="x", padx=30, pady=10)

func_title = Label(
    func_frame,
    text="📚 功能介绍（五年级易懂版）",
    font=("微软雅黑", 18, "bold"),
    bg="#FFFAFA",
    fg="#DC143C"
)
func_title.pack(pady=(10, 5))

func_content = Label(
    func_frame,
    text="1. 名言展示：默认显示一句红色励志历史名言，包含名言原文、作者和通俗含义，适合五年级理解；\n2. 切换功能：点击「上一句」「下一句」按钮，可切换5句不同的爱国励志名言，反复学习；\n3. 红色教育：所有名言均围绕爱国、奉献、成长主题，传递红色正能量，引导我们热爱祖国、努力成长；\n4. 界面操作：窗口固定尺寸，按钮清晰，操作简单，无需复杂步骤，打开即可使用。",
    font=("微软雅黑", 14),
    bg="#FFFAFA",
    fg="#333333",
    justify=tk.LEFT,
    wraplength=900
)
func_content.pack(pady=(5, 10), padx=20)

# ---------------------- 署名牌（固定显示，醒目突出，不突兀）----------------------
sign_frame = Frame(root, bg="#FFFAFA")
sign_frame.pack(fill="x", padx=30, pady=5)

sign_label = Label(
    sign_frame,
    text="殷果  东台市实验小学城东分校  506班",
    font=("微软雅黑", 18, "bold"),
    bg="#FFFAFA",
    fg="#DC143C"
)
sign_label.pack(side=tk.RIGHT)

# ---------------------- 底部正能量标语（强化红色主题）----------------------
bottom_frame = Frame(root, bg="#DC143C", height=80)
bottom_frame.pack(fill="x", padx=20, pady=15)

bottom_label = Label(
    bottom_frame,
    text="🇨🇳 读历史名言 · 传红色基因 · 做爱国少年 🇨🇳",
    font=("微软雅黑", 18, "bold"),
    bg="#DC143C",
    fg="white",
    justify=tk.CENTER
)
bottom_label.place(relx=0.5, rely=0.5, anchor="center")

# 启动主窗口（功能全部可用，直接运行即可）
root.mainloop()
