265 lines
8.9 KiB
Python
265 lines
8.9 KiB
Python
# coding: gb2312
|
||
from PyQt5.QtCore import Qt, QSize
|
||
from PyQt5.QtWidgets import *
|
||
from BaseFrontend.based_widget import BasedWidget
|
||
from PyQt5.QtGui import QIcon
|
||
|
||
|
||
class HomePageWidgetDefine(BasedWidget):
|
||
|
||
def __init__(self):
|
||
super().__init__()
|
||
# 定义控件(按Ctrl+点击快速跳转编辑)
|
||
"""**布局对象初始化区**布局对象初始化区**布局对象初始化区**布局对象初始化区**布局对象初始化区**布局对象初始化区"""
|
||
# 空白控件
|
||
self.empty_box = self._init_empty_widget()
|
||
# 图像控件
|
||
self.image_widget = self._init_image_widget()
|
||
# 六项动作控件
|
||
self.sit_up_widget = self._init_sit_up_widget()
|
||
self.pull_up_widget = self._init_pull_up_widget()
|
||
self.hanging_up_widget = self._init_hanging_up_widget()
|
||
self.push_up_widget = self._init_push_up_widget()
|
||
self.runaround_widget = self._init_runaround_widget()
|
||
self.running_widget = self._init_running_widget()
|
||
# WiFi控件
|
||
self.wifi_widget = self.init_wifi_widget()
|
||
self.wifi_disconnect_widget = self.init_wifi_disconnect_widget()
|
||
self.wifi_stacked_widget = QStackedWidget()
|
||
self.wifi_stacked_widget.addWidget(self.wifi_disconnect_widget)
|
||
self.wifi_stacked_widget.addWidget(self.wifi_widget)
|
||
# 动作和标准的标题和内容定义
|
||
self.standard_title = self._init_standard_title_widget()
|
||
self.standard_value = self._init_standard_value_widget()
|
||
self.difficulty_title = self._init_difficulty_title_widget()
|
||
self.difficulty_value = self._init_difficulty_value_widget()
|
||
# 同步按钮定义
|
||
self.data_synchronization_button = self._init_data_synchronization_widget()
|
||
self.score_synchronization_button = self._init_score_synchronization_widget()
|
||
# logo定义
|
||
self.logo_label = self._init_logo_widget()
|
||
|
||
# 初始化空白控件
|
||
@staticmethod
|
||
def _init_empty_widget():
|
||
empty_widget = QFrame()
|
||
empty_widget.setFrameShape(QFrame.Box)
|
||
empty_widget.setLineWidth(0)
|
||
return empty_widget
|
||
|
||
# 初始化图像控件
|
||
@staticmethod
|
||
def _init_image_widget():
|
||
image_widget = QLabel()
|
||
image_widget.setStyleSheet(
|
||
"border-image: url(assets/main.png) 0 0 0 0 stretch stretch;"
|
||
)
|
||
image_widget.setAlignment(Qt.AlignCenter)
|
||
image_widget.setScaledContents(True)
|
||
return image_widget
|
||
|
||
@staticmethod
|
||
def _init_sit_up_widget():
|
||
sit_up = QPushButton()
|
||
sit_up.setStyleSheet(
|
||
"border-image: url(assets/ywqz.png);"
|
||
"background-size: contain;"
|
||
"background-repeat: no-repeat;"
|
||
"background-position: center;"
|
||
"margin: 5 20 5 20;"
|
||
)
|
||
sit_up.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||
return sit_up
|
||
|
||
@staticmethod
|
||
def _init_pull_up_widget():
|
||
pull_up = QPushButton()
|
||
pull_up.setStyleSheet(
|
||
"border-image: url(assets/ytxs.png);"
|
||
"background-size: contain;"
|
||
"background-repeat: no-repeat;"
|
||
"background-position: center;"
|
||
"margin: 5 20 5 20;"
|
||
)
|
||
pull_up.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||
return pull_up
|
||
|
||
@staticmethod
|
||
def _init_hanging_up_widget():
|
||
hanging_up = QPushButton()
|
||
hanging_up.setStyleSheet(
|
||
"border-image: url(assets/qbxc.png);"
|
||
"background-size: contain;"
|
||
"background-repeat: no-repeat;"
|
||
"background-position: center;"
|
||
"margin: 5 20 5 20;"
|
||
)
|
||
hanging_up.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||
return hanging_up
|
||
|
||
@staticmethod
|
||
def _init_push_up_widget():
|
||
push_up = QPushButton()
|
||
push_up.setStyleSheet(
|
||
"border-image: url(assets/fwc.png);"
|
||
"background-size: contain;"
|
||
"background-repeat: no-repeat;"
|
||
"background-position: center;"
|
||
"margin: 5 20 5 20;"
|
||
)
|
||
push_up.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||
return push_up
|
||
|
||
@staticmethod
|
||
def _init_runaround_widget():
|
||
runaround = QPushButton()
|
||
runaround.setStyleSheet(
|
||
"border-image: url(assets/sxp.png);"
|
||
"background-size: contain;"
|
||
"background-repeat: no-repeat;"
|
||
"background-position: center;"
|
||
"margin: 5 20 5 20;"
|
||
)
|
||
runaround.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||
return runaround
|
||
|
||
@staticmethod
|
||
def _init_running_widget():
|
||
running = QPushButton()
|
||
running.setStyleSheet(
|
||
"border-image: url(assets/sqm.png);"
|
||
"background-size: contain;"
|
||
"background-repeat: no-repeat;"
|
||
"background-position: center;"
|
||
"margin:5 20 5 20;"
|
||
)
|
||
running.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||
return running
|
||
|
||
@staticmethod
|
||
def init_wifi_widget():
|
||
wifi_frame = QPushButton()
|
||
icon = QIcon("assets/wifi.png")
|
||
wifi_frame.setIconSize(QSize(70, 70))
|
||
wifi_frame.setIcon(icon)
|
||
wifi_frame.setStyleSheet(
|
||
"background-color: qlineargradient("
|
||
"spread: pad,"
|
||
"x1: 0,"
|
||
"y1: 0,"
|
||
"x2: 1,"
|
||
"y2: 1,"
|
||
"stop: 0 rgba(113, 183, 255, 255),"
|
||
"stop: 1 rgba(79, 149, 224, 255),"
|
||
"stop: 2 rgba(56, 147, 242, 255));"
|
||
"border-style: none;"
|
||
"border-radius: 50%;"
|
||
"height: 100px;"
|
||
)
|
||
return wifi_frame
|
||
|
||
@staticmethod
|
||
def init_wifi_disconnect_widget():
|
||
wifi_disconnect_widget = QPushButton()
|
||
icon = QIcon("assets/wifi.png")
|
||
wifi_disconnect_widget.setIconSize(QSize(70, 70))
|
||
wifi_disconnect_widget.setIcon(icon)
|
||
wifi_disconnect_widget.setStyleSheet(
|
||
"background-color: #c2c2c3;"
|
||
"border-style: none;"
|
||
"border-radius: 50%;"
|
||
"height: 100px;"
|
||
)
|
||
return wifi_disconnect_widget
|
||
|
||
@staticmethod
|
||
def _init_standard_title_widget():
|
||
standard_title = QLabel("动作标准:")
|
||
standard_title.setStyleSheet(
|
||
"font: 24px \"Microsoft YaHei UI\";"
|
||
)
|
||
return standard_title
|
||
|
||
@staticmethod
|
||
def _init_difficulty_title_widget():
|
||
difficulty_title = QLabel("动作难度:")
|
||
difficulty_title.setStyleSheet(
|
||
"font: 24px \"Microsoft YaHei UI\";"
|
||
)
|
||
return difficulty_title
|
||
|
||
@staticmethod
|
||
def _init_standard_value_widget():
|
||
standard_value = QLabel("<动作标准>")
|
||
standard_value.setStyleSheet(
|
||
"font:700 24px \"Microsoft YaHei UI\";"
|
||
)
|
||
return standard_value
|
||
|
||
@staticmethod
|
||
def _init_difficulty_value_widget():
|
||
difficulty_value = QLabel("<动作难度>")
|
||
difficulty_value.setStyleSheet(
|
||
"font:700 24px \"Microsoft YaHei UI\";"
|
||
)
|
||
return difficulty_value
|
||
|
||
@staticmethod
|
||
def _init_data_synchronization_widget():
|
||
synchronization_widget = QPushButton("数据同步")
|
||
synchronization_widget.setContentsMargins(30, 0, 30, 0)
|
||
synchronization_widget.setStyleSheet(
|
||
"height: 100px;"
|
||
"font: 700 35px \"Microsoft YaHei UI\";"
|
||
"background-color: qlineargradient("
|
||
"spread: pad,"
|
||
"x1: 0,"
|
||
"y1: 0,"
|
||
"x2: 1,"
|
||
"y2: 1,"
|
||
"stop: 0 rgba(113, 183, 255, 255), "
|
||
"stop: 1 rgba(79, 149, 224, 255),"
|
||
"stop: 2 rgba(56, 147, 242, 255));"
|
||
"border: none;"
|
||
"color: #ffffff;"
|
||
"letter-spacing: 10px;"
|
||
"border-radius: 4px;"
|
||
)
|
||
return synchronization_widget
|
||
|
||
@staticmethod
|
||
def _init_score_synchronization_widget():
|
||
synchronization_widget = QPushButton("成绩同步")
|
||
synchronization_widget.setContentsMargins(30, 0, 30, 0)
|
||
synchronization_widget.setStyleSheet(
|
||
"height:100px;"
|
||
"font:700 35px \"Microsoft YaHei UI\";"
|
||
"background-color: qlineargradient("
|
||
"spread: pad,"
|
||
"x1: 0,"
|
||
"y1: 0,"
|
||
"x2: 1,"
|
||
"y2: 1,"
|
||
"stop: 0 rgba(113, 183, 255, 255), "
|
||
"stop: 1 rgba(79, 149, 224, 255),"
|
||
"stop: 2 rgba(56, 147, 242, 255));"
|
||
"border: none;"
|
||
"color: #ffffff;"
|
||
"letter-spacing: 10px;"
|
||
"border-radius: 4px;"
|
||
)
|
||
return synchronization_widget
|
||
|
||
@staticmethod
|
||
def _init_logo_widget():
|
||
logo = QLabel()
|
||
logo.setStyleSheet(
|
||
"border-image: url(assets/logo.png);"
|
||
"background-size: contain;"
|
||
"background-repeat: no-repeat;"
|
||
"background-position: center;"
|
||
)
|
||
logo.setAlignment(Qt.AlignCenter)
|
||
logo.setScaledContents(True)
|
||
return logo
|