阅读我的代码，帮我删除主页，把编辑区变成主页，把主页的按钮移动到编辑区，给我完整代码，不要修改别的内容import sys
import json
from PyQt5.QtWidgets import (
    QApplication, QMainWindow, QPushButton, QVBoxLayout, QWidget, QDialog, QTableWidget, QLabel, QLineEdit, QHBoxLayout,
    QTableWidgetItem, QFileDialog, QMessageBox
)
from PyQt5.QtGui import QIcon, QFont, QFontDatabase, QColor, QPixmap
from PyQt5.QtCore import Qt, QPoint
import os


class ConfigEditor(QDialog):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("配置编辑器")
        self.setGeometry(300, 300, 800, 600)

        # 加载字体
        font_db = QFontDatabase()
        font_id = font_db.addApplicationFont("gui/SDK_SC_Web65.ttf")
        font_family = font_db.applicationFontFamilies(font_id)[0]
        self.setFont(QFont(font_family, 12, QFont.Bold))

        # 创建主体布局
        main_layout = QVBoxLayout()
        self.setLayout(main_layout)

        # 左侧的表格
        self.table_widget = QTableWidget()
        self.table_widget.setSelectionMode(QTableWidget.MultiSelection)
        self.table_widget.setRowCount(5)  # 默认行数
        self.table_widget.setColumnCount(5)  # 默认列数
        main_layout.addWidget(self.table_widget)

        # 右侧的编辑区
        edit_layout = QVBoxLayout()

        # 编辑班级名
        class_name_label = QLabel("班级名:")
        class_name_label.setFont(QFont(font_family, 12, QFont.Bold))
        self.class_name_edit = QLineEdit()
        self.class_name_edit.setFont(QFont(font_family, 12, QFont.Bold))
        self.class_name_edit.setStyleSheet("QLineEdit { border: 2px solid black; border-radius: 3px; padding: 5px; }")
        self.class_name_edit.textChanged.connect(self.update_class_name)
        edit_layout.addWidget(class_name_label)
        edit_layout.addWidget(self.class_name_edit)

        # 创建基本操作按钮
        self.create_button("增加行", self.add_row, edit_layout, font_family)
        self.create_button("减少行", self.remove_row, edit_layout, font_family)
        self.create_button("增加列", self.add_column, edit_layout, font_family)
        self.create_button("减少列", self.remove_column, edit_layout, font_family)

        # 添加新按钮：设置为过道、设置为讲台、设置为墙、设置为门
        self.create_button("设置为过道", self.mark_as_aisle, edit_layout, font_family)
        self.create_button("设置为讲台", self.mark_as_desk, edit_layout, font_family)
        self.create_button("设置为墙", self.mark_as_wall, edit_layout, font_family)
        self.create_button("设置为门", self.mark_as_door, edit_layout, font_family)

        # 设置为排座格
        mark_seating_button = QPushButton("设置为排座格")
        mark_seating_button.setFont(QFont(font_family, 12, QFont.Bold))
        mark_seating_button.setStyleSheet("QPushButton { background-color: white; border: 2px solid black; border-radius: 10px; height: 50px; }")
        mark_seating_button.clicked.connect(self.mark_as_seating)
        edit_layout.addWidget(mark_seating_button)

        # 编辑班级人员
        edit_students_button = QPushButton("编辑班级人员")
        edit_students_button.setFont(QFont(font_family, 12, QFont.Bold))
        edit_students_button.setStyleSheet("QPushButton { background-color: white; border: 2px solid black; border-radius: 10px; height: 50px; }")
        edit_students_button.clicked.connect(self.open_student_editor)
        edit_layout.addWidget(edit_students_button)

        # 保存配置
        save_config_button = QPushButton("保存配置")
        save_config_button.setFont(QFont(font_family, 12, QFont.Bold))
        save_config_button.setStyleSheet("QPushButton { background-color: white; border: 2px solid black; border-radius: 10px; height: 50px; }")
        save_config_button.clicked.connect(self.save_config)
        edit_layout.addWidget(save_config_button)

        # 打开配置
        load_config_button = QPushButton("打开配置")
        load_config_button.setFont(QFont(font_family, 12, QFont.Bold))
        load_config_button.setStyleSheet("QPushButton { background-color: white; border: 2px solid black; border-radius: 10px; height: 50px; }")
        load_config_button.clicked.connect(self.open_config)
        edit_layout.addWidget(load_config_button)

        main_layout.addLayout(edit_layout)

        self.selected_cells = []  # 用于保存选中的单元格
        self.cell_types = {}  # 用于存储单元格类型及其颜色
        self.students = {}  # 用于存储学生信息

        # 更新初始化班级名
        self.update_class_name()

    def create_button(self, text, callback, layout, font_family):
        button = QPushButton(text)
        button.setFont(QFont(font_family, 12, QFont.Bold))  # 确保字体一致
        button.setStyleSheet("QPushButton { background-color: white; border: 2px solid black; border-radius: 10px; height: 50px; }")
        button.clicked.connect(callback)
        layout.addWidget(button)

    def update_class_name(self):
        # 通过合并操作显示班级名，合并2行
        if self.table_widget.rowCount() >= 2:
            self.table_widget.setSpan(0, 0, 2, self.table_widget.columnCount())

        # 更新班级名显示
        class_name = self.class_name_edit.text()
        if class_name:
            label_item = QLabel(class_name)
            label_item.setAlignment(Qt.AlignCenter)
            label_item.setStyleSheet("QLabel { border: 2px solid black; padding: 5px; }")  # 黑色实心边框
            self.table_widget.setCellWidget(0, 0, label_item)

        # 更新表格中的显示
        for (row, col), (cell_type, color) in self.cell_types.items():
            self.update_cell_visual(row, col, cell_type, color)

        # 更新学生信息
        for row, student in self.students.items():
            item = QTableWidgetItem(student)
            item.setTextAlignment(Qt.AlignCenter)
            self.table_widget.setItem(row, 0, QTableWidgetItem(str(row + 1)))  # 学号
            self.table_widget.setItem(row, 1, item)

    def update_cell_visual(self, row, col, cell_type, color):
        if cell_type:  # 只在 cell_type 有值时更新显示
            label_item = QLabel(cell_type)
            label_item.setAlignment(Qt.AlignCenter)
            label_item.setStyleSheet(f"background-color: {color.name()}; border: none; padding: 5px;") 
            self.table_widget.setCellWidget(row, col, label_item)

    def add_row(self):
        current_row_count = self.table_widget.rowCount()
        self.table_widget.insertRow(current_row_count)
        self.cell_types[(current_row_count, 0)] = (None, QColor(255, 255, 255))  # 初始化类型和颜色
        self.update_class_name()

    def remove_row(self):
        current_row_count = self.table_widget.rowCount()
        if current_row_count > 1:
            self.table_widget.removeRow(current_row_count - 1)
            for col in range(self.table_widget.columnCount()):
                if (current_row_count - 1, col) in self.cell_types:
                    del self.cell_types[(current_row_count - 1, col)]  # 移除类型及颜色
        self.update_class_name()

    def add_column(self):
        current_col_count = self.table_widget.columnCount()
        self.table_widget.insertColumn(current_col_count)
        for row in range(self.table_widget.rowCount()):
            self.cell_types[(row, current_col_count)] = (None, QColor(255, 255, 255))  # 初始化类型和颜色
        self.update_class_name()

    def remove_column(self):
        current_col_count = self.table_widget.columnCount()
        if current_col_count > 1:
            self.table_widget.removeColumn(current_col_count - 1)
            for row in range(self.table_widget.rowCount()):
                if (row, current_col_count - 1) in self.cell_types:
                    del self.cell_types[(row, current_col_count - 1)]  # 移除类型及颜色
        self.update_class_name()

    def mark_as_aisle(self):
        self.mark_cells("过道", QColor(144, 238, 144))  # 浅绿色

    def mark_as_desk(self):
        self.mark_cells("讲台", QColor(210, 180, 140))  # 浅棕色

    def mark_as_wall(self):
        self.mark_cells("墙", QColor(169, 169, 169))  # 灰色

    def mark_as_door(self):
        self.mark_cells("门", QColor(255, 255, 224))  # 浅黄色

    def mark_cells(self, cell_type, color):
        if not self.selected_cells:
            return

        # 合并选择的单元格
        first_row, first_col = self.selected_cells[0].y(), self.selected_cells[0].x()
        last_row, last_col = self.selected_cells[-1].y(), self.selected_cells[-1].x()

        # 合并选择的单元格
        self.table_widget.setSpan(first_row, first_col, last_row - first_row + 1, last_col - first_col + 1)

        # 更新cell_types字典
        for row in range(first_row, last_row + 1):
            for col in range(first_col, last_col + 1):
                self.cell_types[(row, col)] = (cell_type, color)  # 保存类型和颜色

        # 更新区域显示
        self.update_cell_visual(first_row, first_col, cell_type, color)

        # 清空选中的单元格
        self.selected_cells.clear()

    def mark_as_seating(self):
        for cell in self.selected_cells:
            item = QTableWidgetItem()
            item.setBackground(QColor(180, 180, 180))  # 设置背景颜色为灰色
            item.setTextAlignment(Qt.AlignCenter)
            self.table_widget.setItem(cell.row(), cell.column(), item)
            self.table_widget.item(cell.row(), cell.column()).setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable) 

        self.selected_cells.clear()  # 清空选中的单元格

    def mousePressEvent(self, event):
        if event.button() == Qt.LeftButton:
            self.start_point = self.table_widget.indexAt(event.pos())
            if self.start_point.isValid():
                self.selected_cells = [self.start_point]

    def mouseMoveEvent(self, event):
        if event.buttons() & Qt.LeftButton:
            end_point = self.table_widget.indexAt(event.pos())
            if end_point.isValid() and end_point != self.start_point:
                rows = range(min(self.start_point.row(), end_point.row()), max(self.start_point.row(), end_point.row()) + 1)
                cols = range(min(self.start_point.column(), end_point.column()), max(self.start_point.column(), end_point.column()) + 1)
                self.selected_cells = [QPoint(row, col) for row in rows for col in cols]
                self.table_widget.clearSelection()
                for cell in self.selected_cells:
                    if self.table_widget.item(cell.row(), cell.column()) is not None:
                        self.table_widget.item(cell.row(), cell.column()).setSelected(True)

    def open_student_editor(self):
        student_editor = StudentEditor(self.students)
        if student_editor.exec_():
            self.students = student_editor.students
            self.update_class_name()

    def save_config(self):
        file_dialog = QFileDialog(self)
        file_dialog.setDefaultSuffix(".json")
        file_path, _ = file_dialog.getSaveFileName(self, "保存配置", "", "JSON Files (*.json)")
        if file_path:
            config_data = {
                "class_name": self.class_name_edit.text(),
                "row_count": self.table_widget.rowCount(),
                "column_count": self.table_widget.columnCount(),
                "cell_types": {str(k): list(v) for k, v in self.cell_types.items()},
                "students": self.students
            }
            with open(file_path, "w", encoding="utf-8") as file:
                json.dump(config_data, file, ensure_ascii=False, indent=4)
            QMessageBox.information(self, "保存成功", f"配置已保存到 {file_path}")

    def open_config(self):
        file_dialog = QFileDialog(self)
        file_path, _ = file_dialog.getOpenFileName(self, "打开配置", "", "JSON Files (*.json)")
        if file_path:
            with open(file_path, "r", encoding="utf-8") as file:
                config_data = json.load(file)
            self.class_name_edit.setText(config_data.get("class_name", ""))
            self.table_widget.setRowCount(config_data.get("row_count", 5))
            self.table_widget.setColumnCount(config_data.get("column_count", 5))
            self.cell_types = {tuple(map(int, k.split(','))): tuple(v) for k, v in config_data.get("cell_types", {}).items()}
            self.students = config_data.get("students", {})
            self.update_class_name()
            QMessageBox.information(self, "加载成功", f"配置已从 {file_path} 加载")

    def start_seating(self):
        # 这里可以添加开始排座的逻辑
        QMessageBox.information(self, "开始排座", "开始排座功能已触发")

    def export_as_png(self):
        # 这里可以添加导出为PNG的逻辑
        QMessageBox.information(self, "导出为PNG", "导出为PNG功能已触发")


class StudentEditor(QDialog):
    def __init__(self, students):
        super().__init__()
        self.setWindowTitle("编辑班级人员")
        self.setGeometry(300, 300, 600, 400)

        # 加载字体
        font_db = QFontDatabase()
        font_id = font_db.addApplicationFont("gui/SDK_SC_Web65.ttf")
        font_family = font_db.applicationFontFamilies(font_id)[0]
        self.setFont(QFont(font_family, 12, QFont.Bold))

        # 创建布局管理器
        layout = QVBoxLayout()
        self.setLayout(layout)

        # 创建表格
        self.table_widget = QTableWidget()
        self.table_widget.setRowCount(len(students) + 10)  # 无限长的表格，多预留10行
        self.table_widget.setColumnCount(2)  # 两列
        self.table_widget.setHorizontalHeaderLabels(["学号", "姓名"])
        layout.addWidget(self.table_widget)

        # 填充学号和学生姓名
        for row, student in students.items():
            item = QTableWidgetItem(student)
            item.setTextAlignment(Qt.AlignCenter)
            self.table_widget.setItem(row, 0, QTableWidgetItem(str(row + 1)))  # 学号
            self.table_widget.setItem(row, 1, item)

        # 创建确定按钮
        confirm_button = QPushButton("确定")
        confirm_button.setFont(QFont(font_family, 12, QFont.Bold))
        confirm_button.setStyleSheet("QPushButton { background-color: white; border: 2px solid black; border-radius: 10px; height: 50px; }")
        confirm_button.clicked.connect(self.accept)
        layout.addWidget(confirm_button)

        self.students = students

    def accept(self):
        new_students = {}
        for row in range(self.table_widget.rowCount()):
            student_id_item = self.table_widget.item(row, 0)
            student_name_item = self.table_widget.item(row, 1)
            if student_name_item and student_name_item.text():
                new_students[row] = student_name_item.text()
        self.students = new_students
        super().accept()


class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("班级随机排座位系统")
        self.setGeometry(300, 300, 800, 600)

        # 设置窗口图标
        self.setWindowIcon(QIcon("icon.ico"))

        # 创建配置编辑器
        config_editor = ConfigEditor()
        config_editor.exec_()

        # 创建按钮
        start_seating_button = QPushButton("开始排座")
        start_seating_button.setFont(QFont("gui/SDK_SC_Web65.ttf", 12, QFont.Bold))
        start_seating_button.setStyleSheet("QPushButton { color: red; background-color: white; border: 2px solid black; border-radius: 10px; height: 50px; }")
        start_seating_button.clicked.connect(config_editor.start_seating)

        export_png_button = QPushButton("导出为PNG")
        export_png_button.setFont(QFont("gui/SDK_SC_Web65.ttf", 12, QFont.Bold))
        export_png_button.setStyleSheet("QPushButton { color: red; background-color: white; border: 2px solid black; border-radius: 10px; height: 50px; }")
        export_png_button.clicked.connect(config_editor.export_as_png)

        # 底部灰色小字
        version_label = QLabel("RandomSeat Ver 1.0")
        version_label.setFont(QFont("gui/SDK_SC_Web65.ttf", 10))
        version_label.setStyleSheet("QLabel { color: gray; }")
        version_label.setAlignment(Qt.AlignCenter)

        # 创建布局管理器
        layout = QVBoxLayout()
        container = QWidget()
        container.setLayout(layout)

        # 在底部添加按钮和版本标签
        layout.addWidget(start_seating_button)
        layout.addWidget(export_png_button)
        layout.addWidget(version_label)

        # 设置内容窗口部件
        self.setCentralWidget(container)

        # 显示配置编辑器
        config_editor.show()


if __name__ == "__main__":
    app = QApplication(sys.argv)
    # 加载字体
    font_db = QFontDatabase()
    font_id = font_db.addApplicationFont("gui/SDK_SC_Web65.ttf")
    font_family = font_db.applicationFontFamilies(font_id)[0]
    app.setFont(QFont(font_family, 12, QFont.Bold))  # 设置全局字体
    window = MainWindow()
    window.show()
    sys.exit(app.exec_())