# coding: gb2312 from PyQt5.QtCore import Qt, QSize from PyQt5.QtGui import QIcon from PyQt5.QtWidgets import * import demo_dataset from BaseFrontend.based_widget import BasedWidget from LSZXPagesLibrary.video_displayer_opengl import VideoDisplayer class PreparePageWidgetDefine(BasedWidget): def __init__(self): super().__init__() # 定义控件(按Ctrl+点击快速跳转编辑) """**布局对象初始化区**布局对象初始化区**布局对象初始化区**布局对象初始化区**布局对象初始化区**布局对象初始化区""" # 空白控件 self.empty_box = self._init_empty_widget() # 标题 self.title_label = self._init_title_label() # 回家按钮 self.back_home_button = self._init_back_button_widget() # 一条直线 self.line_widget = self._init_line_widget() # 编号 self.id_title = self._init_id_title() self.id_box = self._init_id_box() # 姓名 self.name_title = self._init_name_title() self.name_box = self._init_name_box() # 班级 self.class_title = self._init_class_title() self.class_box = self._init_class_box() # 视频流(暂时使用测试视频流) # TODO:替换为正式视频流 self.video_displayer = VideoDisplayer() # 开始按键 self.start_button = self._init_start_button() # 图标 self.logo_label = self._init_logo_label() # 初始化空白控件 @staticmethod def _init_empty_widget(): empty_widget = QFrame() empty_widget.setFrameShape(QFrame.Box) empty_widget.setLineWidth(0) return empty_widget @staticmethod def _init_title_label(): title_label = QLabel("<训练课目名称>") title_label.setAlignment(Qt.AlignCenter) title_label.setStyleSheet("font: 30px \"Microsoft YaHei UI\";letter-spacing: 4px") return title_label @staticmethod def _init_back_button_widget(): back_home_button = QPushButton("返回首页") icon = QIcon("assets/home.png") back_home_button.setIconSize(QSize(32, 32)) back_home_button.setIcon(icon) back_home_button.setStyleSheet( "font: 24px \"Microsoft YaHei UI\";" "border:none;" "color:#222222;" "letter-spacing: 10px;" "border-radius:4px;" "border:1px solid #222222" ";height: 60%;" ) return back_home_button @staticmethod def _init_line_widget(): line = QFrame() line.setFixedHeight(1) # 设置高度为 2 像素 line.setStyleSheet("border:1px solid #000000") line.setFrameShape(QFrame.HLine) # 设置为水平线 return line @staticmethod def _init_id_title(): id_title = QLabel("编号:") id_title.setAlignment(Qt.AlignRight | Qt.AlignVCenter) id_title.setStyleSheet("font: 28px \"Microsoft YaHei UI\";letter-spacing: 4px;") return id_title @staticmethod def _init_id_box(): id_box = QLabel("<人员编号>") id_box.setContentsMargins(0, 0, 0, 0) id_box.setStyleSheet( "font:600 28px \"Microsoft YaHei UI\";" "letter-spacing: 4px;" "padding-left:10px;" "border: 1px solid #222222;" "border-radius:4px" ) return id_box @staticmethod def _init_name_title(): name_title = QLabel("姓名:") name_title.setAlignment(Qt.AlignRight | Qt.AlignVCenter) name_title.setStyleSheet("font: 28px \"Microsoft YaHei UI\";letter-spacing: 4px;") return name_title @staticmethod def _init_name_box(): name_box = QLabel("<人员姓名>") name_box.setContentsMargins(0, 0, 0, 0) name_box.setStyleSheet( "font:600 28px \"Microsoft YaHei UI\";" "letter-spacing: 4px;" "padding-left:10px;" "border: 1px solid #222222;" "border-radius:4px" ) return name_box @staticmethod def _init_class_title(): class_title = QLabel("班级:") class_title.setAlignment(Qt.AlignRight | Qt.AlignVCenter) class_title.setStyleSheet("font: 28px \"Microsoft YaHei UI\";letter-spacing: 4px;") return class_title @staticmethod def _init_class_box(): class_box = QLabel("<班级>") class_box.setContentsMargins(0, 0, 0, 0) class_box.setStyleSheet( "font:600 28px \"Microsoft YaHei UI\";" "letter-spacing: 4px;" "padding-left:10px;" "border: 1px solid #222222;" "border-radius:4px" ) return class_box @staticmethod def _init_start_button(): start_button = QPushButton("开始测试") start_button.setStyleSheet( "font:600 28px \"Microsoft YaHei UI\";" "border:none;" "color:#ffffff;" "letter-spacing: 10px;" "border-radius:4px;" "height: 70%;" "background-color: #67c23a;" ) return start_button @staticmethod def _init_logo_label(): logo_img = QLabel() logo_img.setFrameShape(QFrame.Box) logo_img.setLineWidth(0) logo_img.setStyleSheet( "border-image: url(assets/logo.png);" "background-size: contain;" "background-repeat: no-repeat;" "background-position: center;" ) logo_img.setAlignment(Qt.AlignCenter) logo_img.setScaledContents(True) return logo_img