# coding: gb2312 from PyQt5.QtCore import Qt, QSize from PyQt5.QtGui import QIcon from PyQt5.QtWidgets import * from BaseFrontend.based_widget import BasedWidget class RunningConfigPageWidgetDefine(BasedWidget): def __init__(self): super().__init__() # 定义控件(按Ctrl+点击快速跳转编辑) """**布局对象初始化区**布局对象初始化区**布局对象初始化区**布局对象初始化区**布局对象初始化区**布局对象初始化区""" # 空白控件 self.empty_box = self._init_empty_widget() # 返回上一页 self.back_pre_button = self._init_back_pre_button() # 标题控件 self.title_label = self._init_title_widget() # 回家按钮 self.back_home_button = self._init_back_button_widget() # 一条直线 self.line_widget = self._init_line_widget() # 总圈数标题 self.round_title = self._init_round_title_widget() # 总圈数减号 self.round_down_button = self._init_round_down_button_widget() # 总圈数数值 self.round_num_widget = self._init_round_num_widget() # 总圈数加号 self.round_add_button = self._init_round_add_button_widget() # 总圈数按钮和数值widget,用于设置边框 self.all_round_button_widget = self._init_all_round_button_widget() # 圈时标题 self.round_time_title = self._init_round_time_title_widget() # 圈时减号 self.round_time_down_button = self._init_round_time_down_button_widget() # 圈时数值 self.round_time_widget = self._init_round_time_num_widget() # 圈时加号 self.round_time_add_button = self._init_round_time_add_button_widget() # 最小圈时按钮和数值widget,用于设置边框 self.round_time_button_widget = self._init_round_time_button_widget() # 语音播报按钮 # self.sound_button = self._init_sound_button_widget() # 语音播报文字提示 # self.sound_label = self._init_sound_label_widget() # 语音播报复选框 self.sound_checkbox = self._init_sound_checkbox_widget() # 请确认参加长跑考试的人员名单提示 self.running_tips_label = self._init_running_tips_label_widget() # 参加长跑人员滚动区域 self.scroll_area = self._init_scroll_area_widget() # 把确认参加考试标题和人员名单区域添加进一个widget,用于设置边框 self.main_widget = self._init_main_widget() # 开始测试按钮 self.start_button = self._init_start_button_widget() # logo图标 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_back_pre_button(): back_pre_button = QPushButton() icon = QIcon("assets/left.png") back_pre_button.setIconSize(QSize(60, 60)) back_pre_button.setIcon(icon) back_pre_button.setStyleSheet( "border: none;" ) return back_pre_button @staticmethod def _init_title_widget(): 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_round_title_widget(): round_title = QLabel("总圈数:") round_title.setStyleSheet( "font: 28px \"Microsoft YaHei UI\";" "letter-spacing: 4px;" ) return round_title # 初始化总圈数减号 @staticmethod def _init_round_down_button_widget(): round_down_button = QPushButton("-") round_down_button.setStyleSheet( "font: 100px \"Microsoft YaHei UI\";" "color: #ffffff;" "background-color: #409eff;" "height: 100%;" "margin-top: -9px;" "border: none;" ) return round_down_button # 初始化总圈数数值 @staticmethod def _init_round_num_widget(): round_num = QLabel("3") round_num.setAlignment(Qt.AlignCenter) round_num.setStyleSheet( "font: 600 30px \"Microsoft YaHei UI\";" "letter-spacing: 4px;" "border-top: 2px solid #e7e7e7;" "border-bottom: 2px solid #e7e7e7;" "border-left: none;" "border-right: none;" ) return round_num # 初始化总圈数加号 @staticmethod def _init_round_add_button_widget(): round_add_button = QPushButton("+") round_add_button.setStyleSheet( "font: 75px \"Microsoft YaHei UI\";" "color: #ffffff;" "background-color: #409eff;" "height: 100%;" "margin-top: -9px;" "border: none;" ) return round_add_button # 初始化总圈数加号 @staticmethod def _init_all_round_button_widget(): all_round_button_widget = QWidget() all_round_button_widget.setStyleSheet( "border: 2px solid #e7e7e7;" ) return all_round_button_widget # 初始化圈时标题 @staticmethod def _init_round_time_title_widget(): round_time_title = QLabel("最小圈时:") round_time_title.setStyleSheet( "font: 28px \"Microsoft YaHei UI\";" "letter-spacing: 4px;" ) return round_time_title # 初始化圈时减号 @staticmethod def _init_round_time_down_button_widget(): round_time_down_button = QPushButton("-") round_time_down_button.setStyleSheet( "font: 100px \"Microsoft YaHei UI\";" "color: #ffffff;" "background-color: #409eff;" "height: 100%;" "margin-top: -9px;" "border: none;" ) return round_time_down_button # 初始化圈时数值 @staticmethod def _init_round_time_num_widget(): round_time_num = QLabel("60") round_time_num.setAlignment(Qt.AlignCenter) round_time_num.setStyleSheet( "font: 600 30px \"Microsoft YaHei UI\";" "letter-spacing: 4px;" "border-top: 2px solid #e7e7e7;" "border-bottom: 2px solid #e7e7e7;" "border-left: none;" "border-right: none;" ) return round_time_num # 初始化圈时加号 @staticmethod def _init_round_time_add_button_widget(): round_time_add_button = QPushButton("+") round_time_add_button.setStyleSheet( "font: 75px \"Microsoft YaHei UI\";" "color: #ffffff;" "background-color: #409eff;" "height: 100%;" "margin-top: -9px;" "border: none;" ) return round_time_add_button @staticmethod def _init_round_time_button_widget(): round_time_button_widget = QWidget() round_time_button_widget.setStyleSheet( "border: 2px solid #e7e7e7;" ) return round_time_button_widget @staticmethod def _init_sound_label_widget(): sound_label = QLabel("语音播报") sound_label.setStyleSheet( "font: 30px \"Microsoft YaHei UI\";" ) return sound_label @staticmethod def _init_sound_checkbox_widget(): sound_checkbox = QCheckBox("语音播报") sound_checkbox.setStyleSheet( "QCheckBox { font: 30px \"Microsoft YaHei UI\"; }" ) sound_checkbox.setStyleSheet(sound_checkbox.styleSheet() + "QCheckBox:checked { color: #409eff; }") return sound_checkbox @staticmethod def _init_sound_button_widget(): sound_button = QPushButton() sound_button.setFixedWidth(30) sound_button.setStyleSheet( "height: 30px;" "border: 1px solid #222222;" "border-radius: 2px;" "background-color: #ffffff;" ) return sound_button @staticmethod def _init_running_tips_label_widget(): running_tips_label = QLabel("请确认参加长跑考试的人员名单") running_tips_label.setStyleSheet( "font: 24px \"Microsoft YaHei UI\";" "letter-spacing: 4px;" "border: none;" "margin-left: 20px" ) return running_tips_label @staticmethod def init_name_label_widget(): name_label = QLabel() name_label.setAlignment(Qt.AlignCenter) name_label.setStyleSheet( "font: 24px \"Microsoft YaHei UI\";" "color: #101010;" "padding:0;" "border: none;" ) return name_label @staticmethod def init_id_label_widget(): id_label = QLabel() id_label.setAlignment(Qt.AlignCenter) id_label.setStyleSheet( "border: none;" "padding: 4px 28px 4px 28px;" "font: 20px \"Microsoft YaHei UI\";" "margin: 3px 6px 6px 6px;" "background-color: #e7e7e7;" "border-radius: 4px;" "color: #454545;" ) return id_label @staticmethod def init_person_card_widget(): person_card_widget = QWidget() person_card_widget.setStyleSheet( "border-radius: 4px;" "border: 1px solid #bbbbbb;" "margin: 4px 4px 4px 4px;" ) return person_card_widget @staticmethod def _init_scroll_area_widget(): scroll_area = QScrollArea() scroll_area.setWidgetResizable(True) scroll_area.setStyleSheet( "border: none" ) return scroll_area @staticmethod def _init_main_widget(): main_widget = QWidget() main_widget.setStyleSheet( "border:1px solid #bbbbbb;" "border-radius: 4px" ) return main_widget # 初始化开始测试按钮 @staticmethod def _init_start_button_widget(): 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.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) logo_img.setContentsMargins(12, 6, 12, 6) return logo_img