"""
袁隆平人物生平介绍应用
开发者: 卢思成
学校: 东台市第一小学（一小本部）
班级: 六（10）班
版本: 1.0
日期: 2024年
"""

import sys
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
import datetime


class YuanLongpingApp(QMainWindow):
    """
    袁隆平人物生平介绍应用
    作者: 卢思成
    学校: 东台市第一小学（一小本部）
    班级: 六（10）班
    """

    def __init__(self):
        super().__init__()

        # 设置个人信息
        self.developer_info = {
            "name": "卢思成",
            "school": "东台市第一小学（一小本部）",
            "class": "六（10）班",
            "version": "1.0",
            "date": "2024年"
        }

        # 袁隆平生平数据
        self.yuan_data = self.load_yuan_data()

        # 当前显示的照片索引
        self.current_photo_index = 0

        self.init_ui()

    def load_yuan_data(self):
        """加载袁隆平生平数据"""
        return {
            "basic_info": {
                "姓名": "袁隆平",
                "英文名": "Yuan Longping",
                "称号": ["杂交水稻之父", "共和国勋章获得者", "当代神农"],
                "出生": "1930年9月7日",
                "逝世": "2021年5月22日",
                "籍贯": "江西省德安县",
                "职业": ["农业科学家", "中国工程院院士"],
                "主要成就": "杂交水稻技术的研究、应用与推广"
            },

            "life_stages": [
                {
                    "时期": "童年与求学",
                    "时间": "1930-1953",
                    "描述": "袁隆平出生于北京协和医院，在战乱年代随父母辗转多地。\n1949年考入重庆相辉学院农学系，后并入西南农学院。\n1953年毕业于西南农学院（现西南大学），被分配到湖南安江农校任教。"
                },
                {
                    "时期": "研究起步",
                    "时间": "1960-1964",
                    "描述": "1960年，在安江农校试验田中意外发现一株'天然杂交稻'。\n从此开始系统研究水稻杂交优势利用。\n1964年，在稻田中找到6株天然雄性不育株，迈出杂交水稻研究第一步。"
                },
                {
                    "时期": "重大突破",
                    "时间": "1970-1973",
                    "描述": "1970年，助手在海南发现一株花粉败育的野生稻（'野败'），为杂交水稻研究打开突破口。\n1973年，成功培育出世界上第一个杂交水稻品种'南优2号'，实现历史性突破。"
                },
                {
                    "时期": "推广与荣誉",
                    "时间": "1976-至今",
                    "描述": "1976年起，杂交水稻在全国大面积推广，产量大幅提高。\n1981年获得中国第一个特等发明奖。\n1995年当选中国工程院院士。\n2001年获得首届国家最高科学技术奖。\n2019年被授予'共和国勋章'。"
                },
                {
                    "时期": "国际贡献",
                    "时间": "1980-2021",
                    "描述": "为全球80多个国家培训14000多名杂交水稻技术人才。\n在印度、越南、菲律宾、孟加拉国等国推广杂交水稻。\n被誉为'杂交水稻之父'，为解决世界粮食问题做出卓越贡献。"
                }
            ],

            "achievements": [
                {
                    "成就": "杂交水稻技术",
                    "描述": "开创杂交水稻研究领域，使中国水稻产量提高20%以上",
                    "影响": "为中国粮食安全做出重大贡献"
                },
                {
                    "成就": "超级杂交稻",
                    "描述": "提出并实现'种三产四'丰产工程，亩产突破1000公斤",
                    "影响": "推动中国水稻单产世界领先"
                },
                {
                    "成就": "海水稻研究",
                    "描述": "晚年致力于耐盐碱水稻（海水稻）研究，在盐碱地种出水稻",
                    "影响": "为拓展耕地资源提供新途径"
                },
                {
                    "成就": "人才培养",
                    "描述": "培养大批农业科技人才，建立完善的研究团队",
                    "影响": "保障杂交水稻技术持续发展"
                }
            ],

            "quotes": [
                "我毕生的追求就是让所有人远离饥饿。",
                "人就像种子，要做一粒好种子。",
                "我不在家，就在试验田；不在试验田，就在去试验田的路上。",
                "科学研究要勇于探索，勇于创新，这个是关键。",
                "电脑里长不出水稻，书本里也长不出水稻，要种出好水稻必须得下田。"
            ],

            "honors": [
                {"奖项": "国家特等发明奖", "年份": 1981},
                {"奖项": "首届国家最高科学技术奖", "年份": 2001},
                {"奖项": "沃尔夫农业奖", "年份": 2004},
                {"奖项": "世界粮食奖", "年份": 2004},
                {"奖项": "共和国勋章", "年份": 2019}
            ],

            "photos": [
                {"标题": "青年时期的袁隆平", "描述": "在试验田工作的年轻袁隆平"},
                {"标题": "在田间研究", "描述": "袁隆平在稻田中观察水稻生长"},
                {"标题": "指导学生", "描述": "在田间指导青年科研人员"},
                {"标题": "获得共和国勋章", "描述": "2019年获授共和国勋章"},
                {"标题": "国际交流", "描述": "与外国专家交流杂交水稻技术"}
            ],

            "timeline": [
                {"年份": 1930, "事件": "出生于北京"},
                {"年份": 1953, "事件": "西南农学院毕业"},
                {"年份": 1964, "事件": "发现天然雄性不育株"},
                {"年份": 1973, "事件": "培育出'南优2号'杂交水稻"},
                {"年份": 1981, "事件": "获国家特等发明奖"},
                {"年份": 2001, "事件": "获首届国家最高科学技术奖"},
                {"年份": 2019, "事件": "被授予共和国勋章"},
                {"年份": 2021, "事件": "在长沙逝世，享年91岁"}
            ]
        }

    def init_ui(self):
        """初始化用户界面"""
        # 设置窗口属性
        title = f'袁隆平生平事迹介绍 - {self.developer_info["name"]} ({self.developer_info["school"]} {self.developer_info["class"]}) 制作'
        self.setWindowTitle(title)
        self.setGeometry(100, 50, 1200, 800)

        # 设置窗口图标
        self.setWindowIcon(self.create_app_icon())

        # 设置主窗口样式
        self.setStyleSheet("""
            QMainWindow {
                background-color: #f5f5dc;
            }
            QWidget {
                font-family: "Microsoft YaHei", "Arial", sans-serif;
            }
        """)

        # 创建中心部件
        central_widget = QWidget()
        self.setCentralWidget(central_widget)

        # 主布局
        main_layout = QVBoxLayout(central_widget)
        main_layout.setContentsMargins(0, 0, 0, 0)
        main_layout.setSpacing(0)

        # 顶部标题栏
        main_layout.addWidget(self.create_title_bar())

        # 主体内容区域
        content_widget = QWidget()
        content_layout = QHBoxLayout(content_widget)
        content_layout.setContentsMargins(10, 10, 10, 10)
        content_layout.setSpacing(10)

        # 左侧导航栏
        content_layout.addWidget(self.create_sidebar(), 1)

        # 右侧内容显示区
        self.content_stack = QStackedWidget()
        self.content_stack.setStyleSheet("""
            QStackedWidget {
                background-color: white;
                border-radius: 10px;
                border: 2px solid #8B7355;
            }
        """)

        # 创建各个内容页面
        self.content_stack.addWidget(self.create_basic_info_page())
        self.content_stack.addWidget(self.create_life_story_page())
        self.content_stack.addWidget(self.create_achievements_page())
        self.content_stack.addWidget(self.create_honors_page())
        self.content_stack.addWidget(self.create_quotes_page())

        content_layout.addWidget(self.content_stack, 3)

        main_layout.addWidget(content_widget, 1)

        # 底部状态栏
        self.setup_status_bar()

        # 设置初始显示内容
        self.show_basic_info()

    def create_app_icon(self):
        """创建应用程序图标（水稻主题）"""
        pixmap = QPixmap(64, 64)
        pixmap.fill(Qt.transparent)

        painter = QPainter(pixmap)
        painter.setRenderHint(QPainter.Antialiasing)

        # 绘制金色背景
        painter.setBrush(QColor(255, 215, 0, 200))
        painter.drawEllipse(2, 2, 60, 60)

        # 绘制文字"袁"
        painter.setPen(QPen(QColor(139, 69, 19), 2))
        font = QFont("Microsoft YaHei", 16, QFont.Bold)
        painter.setFont(font)
        painter.drawText(QRect(0, 0, 64, 64), Qt.AlignCenter, "袁")

        painter.end()

        return QIcon(pixmap)

    def create_title_bar(self):
        """创建顶部标题栏"""
        title_bar = QWidget()
        title_bar.setFixedHeight(100)
        title_bar.setStyleSheet("""
            QWidget {
                background-color: #228B22;
                border-bottom: 3px solid #006400;
            }
        """)

        layout = QHBoxLayout(title_bar)
        layout.setContentsMargins(20, 10, 20, 10)

        # 左侧：标题
        title_label = QLabel("袁隆平 - 杂交水稻之父")
        title_label.setStyleSheet("""
            QLabel {
                color: white;
                font-size: 28px;
                font-weight: bold;
                padding: 5px;
            }
        """)
        layout.addWidget(title_label)

        # 中间：开发者信息
        dev_widget = QWidget()
        dev_layout = QVBoxLayout(dev_widget)
        dev_layout.setAlignment(Qt.AlignCenter)

        dev_info = f"开发者: {self.developer_info['name']}"
        dev_label = QLabel(dev_info)
        dev_label.setStyleSheet("""
            QLabel {
                color: white;
                font-size: 16px;
                font-weight: bold;
                padding: 3px;
            }
        """)
        dev_layout.addWidget(dev_label)

        school_info = f"{self.developer_info['school']} {self.developer_info['class']}"
        school_label = QLabel(school_info)
        school_label.setStyleSheet("""
            QLabel {
                color: #FFD700;
                font-size: 14px;
                padding: 2px;
            }
        """)
        dev_layout.addWidget(school_label)

        layout.addWidget(dev_widget)

        # 右侧：时间
        time_widget = QWidget()
        time_layout = QVBoxLayout(time_widget)
        time_layout.setAlignment(Qt.AlignRight | Qt.AlignTop)

        # 使用简单的时间格式避免编码问题
        current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
        time_label = QLabel(f"时间: {current_time}")
        time_label.setStyleSheet("""
            QLabel {
                color: white;
                font-size: 14px;
                padding: 2px;
            }
        """)
        time_layout.addWidget(time_label)

        layout.addWidget(time_widget)

        return title_bar

    def create_sidebar(self):
        """创建左侧导航栏"""
        sidebar = QWidget()
        sidebar.setFixedWidth(250)
        sidebar.setStyleSheet("""
            QWidget {
                background-color: rgba(245, 245, 220, 200);
                border-radius: 10px;
                border: 2px solid #8B7355;
            }
        """)

        layout = QVBoxLayout(sidebar)
        layout.setContentsMargins(10, 20, 10, 20)
        layout.setSpacing(15)

        # 导航标题
        nav_title = QLabel("导航菜单")
        nav_title.setStyleSheet("""
            QLabel {
                color: #228B22;
                font-size: 20px;
                font-weight: bold;
                padding: 10px;
                qproperty-alignment: AlignCenter;
                border-bottom: 2px solid #228B22;
            }
        """)
        layout.addWidget(nav_title)

        # 基本信息按钮
        basic_btn = QPushButton("基本信息")
        basic_btn.clicked.connect(self.show_basic_info)
        basic_btn.setStyleSheet("""
            QPushButton {
                background-color: #228B22;
                color: white;
                border: none;
                border-radius: 8px;
                font-size: 15px;
                font-weight: bold;
                padding: 10px;
                text-align: left;
                padding-left: 20px;
            }
            QPushButton:hover {
                background-color: #32CD32;
                border: 2px solid white;
            }
        """)
        basic_btn.setFixedHeight(50)
        layout.addWidget(basic_btn)

        # 生平事迹按钮
        life_btn = QPushButton("生平事迹")
        life_btn.clicked.connect(self.show_life_story)
        life_btn.setStyleSheet("""
            QPushButton {
                background-color: #32CD32;
                color: white;
                border: none;
                border-radius: 8px;
                font-size: 15px;
                font-weight: bold;
                padding: 10px;
                text-align: left;
                padding-left: 20px;
            }
            QPushButton:hover {
                background-color: #228B22;
                border: 2px solid white;
            }
        """)
        life_btn.setFixedHeight(50)
        layout.addWidget(life_btn)

        # 主要成就按钮
        achievement_btn = QPushButton("主要成就")
        achievement_btn.clicked.connect(self.show_achievements)
        achievement_btn.setStyleSheet("""
            QPushButton {
                background-color: #FFD700;
                color: #8B4513;
                border: none;
                border-radius: 8px;
                font-size: 15px;
                font-weight: bold;
                padding: 10px;
                text-align: left;
                padding-left: 20px;
            }
            QPushButton:hover {
                background-color: #FFA500;
                border: 2px solid white;
            }
        """)
        achievement_btn.setFixedHeight(50)
        layout.addWidget(achievement_btn)

        # 荣誉奖项按钮
        honor_btn = QPushButton("荣誉奖项")
        honor_btn.clicked.connect(self.show_honors)
        honor_btn.setStyleSheet("""
            QPushButton {
                background-color: #FF8C00;
                color: white;
                border: none;
                border-radius: 8px;
                font-size: 15px;
                font-weight: bold;
                padding: 10px;
                text-align: left;
                padding-left: 20px;
            }
            QPushButton:hover {
                background-color: #FFA500;
                border: 2px solid white;
            }
        """)
        honor_btn.setFixedHeight(50)
        layout.addWidget(honor_btn)

        # 经典语录按钮
        quote_btn = QPushButton("经典语录")
        quote_btn.clicked.connect(self.show_quotes)
        quote_btn.setStyleSheet("""
            QPushButton {
                background-color: #4682B4;
                color: white;
                border: none;
                border-radius: 8px;
                font-size: 15px;
                font-weight: bold;
                padding: 10px;
                text-align: left;
                padding-left: 20px;
            }
            QPushButton:hover {
                background-color: #1E90FF;
                border: 2px solid white;
            }
        """)
        quote_btn.setFixedHeight(50)
        layout.addWidget(quote_btn)

        # 添加弹簧
        layout.addStretch(1)

        # 底部信息
        footer = QWidget()
        footer_layout = QVBoxLayout(footer)

        version_label = QLabel(f"版本: v{self.developer_info['version']}")
        version_label.setStyleSheet("""
            QLabel {
                color: #696969;
                font-size: 12px;
                padding: 5px;
                qproperty-alignment: AlignCenter;
            }
        """)
        footer_layout.addWidget(version_label)

        date_label = QLabel(f"制作日期: {self.developer_info['date']}")
        date_label.setStyleSheet("""
            QLabel {
                color: #696969;
                font-size: 12px;
                padding: 5px;
                qproperty-alignment: AlignCenter;
            }
        """)
        footer_layout.addWidget(date_label)

        layout.addWidget(footer)

        return sidebar

    def create_basic_info_page(self):
        """创建基本信息页面"""
        widget = QWidget()
        layout = QVBoxLayout(widget)
        layout.setContentsMargins(20, 20, 20, 20)
        layout.setSpacing(20)

        # 页面标题
        title = QLabel("袁隆平 - 基本信息")
        title.setStyleSheet("""
            QLabel {
                color: #228B22;
                font-size: 24px;
                font-weight: bold;
                padding-bottom: 10px;
                border-bottom: 3px solid #228B22;
            }
        """)
        layout.addWidget(title)

        # 创建滚动区域
        scroll = QScrollArea()
        scroll.setWidgetResizable(True)
        scroll.setStyleSheet("""
            QScrollArea {
                border: none;
                background: transparent;
            }
        """)

        scroll_content = QWidget()
        scroll_layout = QVBoxLayout(scroll_content)
        scroll_layout.setSpacing(20)

        # 基本信息表格
        info_group = QGroupBox("基本信息")
        info_group.setStyleSheet("""
            QGroupBox {
                font-size: 16px;
                font-weight: bold;
                color: #228B22;
            }
        """)

        info_layout = QGridLayout()
        basic_info = self.yuan_data["basic_info"]

        row = 0
        for key, value in basic_info.items():
            if key in ["姓名", "英文名", "出生", "逝世", "籍贯", "职业", "主要成就"]:
                key_label = QLabel(f"{key}:")
                key_label.setStyleSheet(
                    "color: #228B22; font-weight: bold; font-size: 14px;")

                if isinstance(value, list):
                    value_text = "、".join(value)
                else:
                    value_text = str(value)

                value_label = QLabel(value_text)
                value_label.setStyleSheet("color: #2F4F4F; font-size: 14px;")
                value_label.setWordWrap(True)

                info_layout.addWidget(key_label, row, 0)
                info_layout.addWidget(value_label, row, 1)
                row += 1

        info_group.setLayout(info_layout)
        scroll_layout.addWidget(info_group)

        # 称号展示
        titles_group = QGroupBox("荣誉称号")
        titles_group.setStyleSheet("""
            QGroupBox {
                font-size: 16px;
                font-weight: bold;
                color: #DAA520;
            }
        """)

        titles_layout = QVBoxLayout()
        titles = basic_info.get("称号", [])

        for title_text in titles:
            title_label = QLabel(f"• {title_text}")
            title_label.setStyleSheet("""
                QLabel {
                    color: #8B4513;
                    font-size: 14px;
                    padding: 5px;
                }
            """)
            titles_layout.addWidget(title_label)

        titles_group.setLayout(titles_layout)
        scroll_layout.addWidget(titles_group)

        # 贡献概述
        contribution_group = QGroupBox("主要贡献")
        contribution_group.setStyleSheet("""
            QGroupBox {
                font-size: 16px;
                font-weight: bold;
                color: #1E90FF;
            }
        """)

        contribution_layout = QVBoxLayout()

        contribution_text = QLabel("""袁隆平院士是享誉海内外的著名农业科学家，中国杂交水稻事业的开创者和领导者。
他发明的杂交水稻技术，为中国的粮食安全、农业科学发展和世界粮食供给作出了杰出贡献。

主要贡献包括：
1. 成功研发杂交水稻技术，使水稻产量大幅提高
2. 提出并实现"超级杂交稻"育种目标
3. 推动杂交水稻的国际合作与推广
4. 晚年致力于耐盐碱水稻（海水稻）研究
5. 培养了大批杂交水稻专业技术人才

他被誉为"杂交水稻之父"，他的研究成果不仅解决了中国人的吃饭问题，也为世界粮食安全做出了重要贡献。""")
        contribution_text.setStyleSheet("""
            QLabel {
                color: #2F4F4F;
                font-size: 14px;
                line-height: 1.6;
            }
        """)
        contribution_text.setWordWrap(True)
        contribution_layout.addWidget(contribution_text)

        contribution_group.setLayout(contribution_layout)
        scroll_layout.addWidget(contribution_group)

        scroll_layout.addStretch()
        scroll.setWidget(scroll_content)
        layout.addWidget(scroll)

        return widget

    def create_life_story_page(self):
        """创建生平事迹页面"""
        widget = QWidget()
        layout = QVBoxLayout(widget)
        layout.setContentsMargins(20, 20, 20, 20)

        # 页面标题
        title = QLabel("袁隆平 - 生平事迹")
        title.setStyleSheet("""
            QLabel {
                color: #32CD32;
                font-size: 24px;
                font-weight: bold;
                padding-bottom: 10px;
                border-bottom: 3px solid #32CD32;
                margin-bottom: 20px;
            }
        """)
        layout.addWidget(title)

        # 创建滚动区域
        scroll = QScrollArea()
        scroll.setWidgetResizable(True)

        scroll_content = QWidget()
        scroll_layout = QVBoxLayout(scroll_content)
        scroll_layout.setSpacing(20)

        # 显示各个阶段
        stages = self.yuan_data["life_stages"]
        for stage in stages:
            stage_card = self.create_stage_card(stage)
            scroll_layout.addWidget(stage_card)

        scroll_layout.addStretch()
        scroll.setWidget(scroll_content)
        layout.addWidget(scroll)

        return widget

    def create_stage_card(self, stage):
        """创建生平阶段卡片"""
        card = QWidget()
        card.setStyleSheet("""
            QWidget {
                background-color: #FAFAD2;
                border-radius: 10px;
                border-left: 5px solid #228B22;
                padding: 20px;
            }
        """)

        layout = QVBoxLayout(card)
        layout.setSpacing(10)

        # 时期和时间
        period_layout = QHBoxLayout()

        period_label = QLabel(stage['时期'])
        period_label.setStyleSheet("""
            QLabel {
                color: #228B22;
                font-size: 18px;
                font-weight: bold;
            }
        """)
        period_layout.addWidget(period_label)

        period_layout.addStretch()

        time_label = QLabel(stage['时间'])
        time_label.setStyleSheet("""
            QLabel {
                color: #8B4513;
                font-size: 16px;
                font-weight: bold;
                background-color: #FFEBCD;
                padding: 5px 15px;
                border-radius: 4px;
            }
        """)
        period_layout.addWidget(time_label)

        layout.addLayout(period_layout)

        # 描述
        desc_label = QLabel(stage['描述'])
        desc_label.setStyleSheet("""
            QLabel {
                color: #2F4F4F;
                font-size: 14px;
                line-height: 1.6;
            }
        """)
        desc_label.setWordWrap(True)
        layout.addWidget(desc_label)

        return card

    def create_achievements_page(self):
        """创建主要成就页面"""
        widget = QWidget()
        layout = QVBoxLayout(widget)
        layout.setContentsMargins(20, 20, 20, 20)

        title = QLabel("袁隆平 - 主要成就")
        title.setStyleSheet("""
            QLabel {
                color: #FFD700;
                font-size: 24px;
                font-weight: bold;
                padding-bottom: 10px;
                border-bottom: 3px solid #FFD700;
                margin-bottom: 20px;
            }
        """)
        layout.addWidget(title)

        # 使用网格布局显示成就
        scroll = QScrollArea()
        scroll.setWidgetResizable(True)

        scroll_content = QWidget()
        scroll_layout = QVBoxLayout(scroll_content)
        scroll_layout.setSpacing(20)

        achievements = self.yuan_data["achievements"]
        for i, achievement in enumerate(achievements):
            achievement_card = self.create_achievement_card(achievement, i)
            scroll_layout.addWidget(achievement_card)

        scroll_layout.addStretch()
        scroll.setWidget(scroll_content)
        layout.addWidget(scroll)

        return widget

    def create_achievement_card(self, achievement, index):
        """创建成就卡片"""
        colors = ["#FFE4B5", "#E0FFFF", "#F0FFF0", "#FFF0F5"]
        color = colors[index % len(colors)]

        card = QWidget()
        card.setStyleSheet(f"""
            QWidget {{
                background-color: {color};
                border-radius: 10px;
                border: 2px solid #FFD700;
                padding: 20px;
            }}
        """)

        layout = QVBoxLayout(card)
        layout.setSpacing(15)

        # 成就标题
        title_label = QLabel(achievement['成就'])
        title_label.setStyleSheet("""
            QLabel {
                color: #8B4513;
                font-size: 18px;
                font-weight: bold;
                qproperty-alignment: AlignCenter;
            }
        """)
        layout.addWidget(title_label)

        # 成就描述
        desc_label = QLabel(achievement['描述'])
        desc_label.setStyleSheet("""
            QLabel {
                color: #2F4F4F;
                font-size: 14px;
                line-height: 1.5;
            }
        """)
        desc_label.setWordWrap(True)
        layout.addWidget(desc_label)

        # 影响
        impact_label = QLabel(f"影响: {achievement['影响']}")
        impact_label.setStyleSheet("""
            QLabel {
                color: #228B22;
                font-size: 13px;
                font-style: italic;
            }
        """)
        impact_label.setWordWrap(True)
        layout.addWidget(impact_label)

        return card

    def create_honors_page(self):
        """创建荣誉奖项页面"""
        widget = QWidget()
        layout = QVBoxLayout(widget)
        layout.setContentsMargins(20, 20, 20, 20)

        title = QLabel("袁隆平 - 荣誉奖项")
        title.setStyleSheet("""
            QLabel {
                color: #FF8C00;
                font-size: 24px;
                font-weight: bold;
                padding-bottom: 10px;
                border-bottom: 3px solid #FF8C00;
                margin-bottom: 20px;
            }
        """)
        layout.addWidget(title)

        # 创建荣誉列表
        scroll = QScrollArea()
        scroll.setWidgetResizable(True)

        scroll_content = QWidget()
        scroll_layout = QVBoxLayout(scroll_content)
        scroll_layout.setSpacing(15)

        honors = self.yuan_data["honors"]
        for i, honor in enumerate(honors):
            honor_item = self.create_honor_item(honor, i)
            scroll_layout.addWidget(honor_item)

        scroll_layout.addStretch()
        scroll.setWidget(scroll_content)
        layout.addWidget(scroll)

        return widget

    def create_honor_item(self, honor, index):
        """创建荣誉奖项项"""
        item = QWidget()
        item.setStyleSheet("""
            QWidget {
                background-color: #FFEBCD;
                border-radius: 8px;
                padding: 15px;
                border-left: 4px solid #FF8C00;
            }
        """)

        layout = QHBoxLayout(item)

        # 年份
        year_label = QLabel(f"{honor['年份']}年")
        year_label.setStyleSheet("""
            QLabel {
                color: #FF4500;
                font-size: 18px;
                font-weight: bold;
                min-width: 80px;
            }
        """)
        layout.addWidget(year_label)

        # 奖项
        award_label = QLabel(honor['奖项'])
        award_label.setStyleSheet("""
            QLabel {
                color: #2F4F4F;
                font-size: 16px;
                font-weight: bold;
            }
        """)
        layout.addWidget(award_label, 1)

        return item

    def create_quotes_page(self):
        """创建经典语录页面"""
        widget = QWidget()
        layout = QVBoxLayout(widget)
        layout.setContentsMargins(20, 20, 20, 20)
        layout.setSpacing(20)

        title = QLabel("袁隆平 - 经典语录")
        title.setStyleSheet("""
            QLabel {
                color: #4682B4;
                font-size: 24px;
                font-weight: bold;
                padding-bottom: 10px;
                border-bottom: 3px solid #4682B4;
                margin-bottom: 20px;
            }
        """)
        layout.addWidget(title)

        # 语录列表
        scroll = QScrollArea()
        scroll.setWidgetResizable(True)

        scroll_content = QWidget()
        scroll_layout = QVBoxLayout(scroll_content)
        scroll_layout.setSpacing(20)

        quotes = self.yuan_data["quotes"]
        for i, quote in enumerate(quotes):
            quote_widget = self.create_quote_widget(quote, i)
            scroll_layout.addWidget(quote_widget)

        scroll_layout.addStretch()
        scroll.setWidget(scroll_content)
        layout.addWidget(scroll)

        return widget

    def create_quote_widget(self, quote, index):
        """创建语录控件"""
        colors = ["#F0F8FF", "#F5F5F5", "#FFF0F5", "#F0FFF0"]
        color = colors[index % len(colors)]

        widget = QWidget()
        widget.setStyleSheet(f"""
            QWidget {{
                background-color: {color};
                border-radius: 10px;
                padding: 20px;
                border: 1px solid #87CEEB;
            }}
        """)

        layout = QVBoxLayout(widget)

        # 语录内容
        quote_label = QLabel(f'"{quote}"')
        quote_label.setStyleSheet("""
            QLabel {
                color: #2F4F4F;
                font-size: 16px;
                font-style: italic;
                line-height: 1.6;
                padding: 10px;
            }
        """)
        quote_label.setWordWrap(True)
        quote_label.setAlignment(Qt.AlignCenter)
        layout.addWidget(quote_label)

        return widget

    def setup_status_bar(self):
        """设置状态栏"""
        status_bar = QStatusBar()
        self.setStatusBar(status_bar)

        # 开发者信息
        dev_info = f"开发者: {self.developer_info['name']} | 学校: {self.developer_info['school']} | 班级: {self.developer_info['class']}"
        status_bar.addWidget(QLabel(dev_info), 1)

        # 当前时间
        self.time_label = QLabel()
        status_bar.addPermanentWidget(self.time_label)

        # 更新时间
        self.update_time()
        self.timer = QTimer()
        self.timer.timeout.connect(self.update_time)
        self.timer.start(1000)

    def update_time(self):
        """更新时间显示"""
        # 使用简单的英文时间格式避免编码问题
        current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        self.time_label.setText(f"时间: {current_time}")

    def show_basic_info(self):
        """显示基本信息"""
        self.content_stack.setCurrentIndex(0)

    def show_life_story(self):
        """显示生平事迹"""
        self.content_stack.setCurrentIndex(1)

    def show_achievements(self):
        """显示主要成就"""
        self.content_stack.setCurrentIndex(2)

    def show_honors(self):
        """显示荣誉奖项"""
        self.content_stack.setCurrentIndex(3)

    def show_quotes(self):
        """显示经典语录"""
        self.content_stack.setCurrentIndex(4)


def main():
    app = QApplication(sys.argv)

    # 设置应用程序样式
    app.setStyle("Fusion")

    # 创建并显示窗口
    window = YuanLongpingApp()
    window.show()

    # 显示启动消息
    QMessageBox.information(window, "欢迎使用",
                            f"""欢迎使用袁隆平人物生平介绍应用！

开发者: {window.developer_info['name']}
学校: {window.developer_info['school']}
班级: {window.developer_info['class']}

本应用详细介绍了"杂交水稻之父"袁隆平院士的生平事迹、主要成就和伟大贡献。

点击左侧导航菜单查看不同内容。""")

    sys.exit(app.exec_())


if __name__ == '__main__':
    main()
