LISHUZUOXUN_yangjiang/LSZXPagesManagerLibrary/display_first.py

338 lines
13 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# coding: gb2312
from PyQt5.QtGui import QColor
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
class DisplayTopOne(QWidget):
def __init__(self):
super().__init__()
# 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.item_widget = self._init_item_widget()
self.badge_widget = self._init_badge_widget()
self.badge_label = self._init_badge_label()
self.top_one_widget = self._init_top_one_widget()
self.top_one_title = self._init_top_one_title()
self.top_one_name = self._init_top_one_name()
self.top_one_score = self._init_top_one_score()
self.sit_up_top = self._init_top_one_widget()
self.sit_up_title = self._init_test_one_title()
self.sit_up_name = self._init_test_one_name()
self.sit_up_score = self._init_test_one_score()
self.pull_up_top = self._init_top_one_widget()
self.pull_up_title = self._init_test_one_title()
self.pull_up_name = self._init_test_one_name()
self.pull_up_score = self._init_test_one_score()
self.runaround_top = self._init_top_one_widget()
self.runaround_title = self._init_test_one_title()
self.runaround_name = self._init_test_one_name()
self.runaround_score = self._init_test_one_score()
self.running_top = self._init_top_one_widget()
self.running_title = self._init_test_one_title()
self.running_name = self._init_test_one_name()
self.running_score = self._init_test_one_score()
self.push_up_top = self._init_top_one_widget()
self.push_up_title = self._init_test_one_title()
self.push_up_name = self._init_test_one_name()
self.push_up_score = self._init_test_one_score()
self.sit_up_title.setText('<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>')
self.pull_up_title.setText('<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>һ<EFBFBD><EFBFBD>')
self.runaround_title.setText('30*2<><32><EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD>һ<EFBFBD><D2BB>')
self.running_title.setText('<EFBFBD><EFBFBD>ǧ<EFBFBD>׵<EFBFBD>һ<EFBFBD><EFBFBD>')
self.push_up_title.setText('<EFBFBD><EFBFBD><EFBFBD>Գŵ<EFBFBD>һ<EFBFBD><EFBFBD>')
self.top_one_bottom_layout = QHBoxLayout()
self.top_one_bottom_layout.setContentsMargins(0, 0, 0, 0)
self.top_one_bottom_layout.addWidget(self.top_one_name, 50)
self.top_one_bottom_layout.addWidget(self.top_one_score, 50)
self.top_one_layout = QVBoxLayout()
self.top_one_layout.setContentsMargins(50, 0, 50, 0)
self.top_one_layout.addWidget(self.top_one_title, 50)
self.top_one_layout.addLayout(self.top_one_bottom_layout, 50)
self.top_one_widget.setLayout(self.top_one_layout)
self.sit_up_bottom_layout = QHBoxLayout()
self.sit_up_bottom_layout.setContentsMargins(0, 0, 0, 0)
self.sit_up_bottom_layout.addWidget(self.sit_up_name, 50)
self.sit_up_bottom_layout.addWidget(self.sit_up_score, 50)
self.sit_up_layout = QVBoxLayout()
self.sit_up_layout.setContentsMargins(20, 0, 20, 0)
self.sit_up_layout.addWidget(self.sit_up_title, 50)
self.sit_up_layout.addLayout(self.sit_up_bottom_layout, 50)
self.sit_up_top.setLayout(self.sit_up_layout)
self.pull_up_bottom_layout = QHBoxLayout()
self.pull_up_bottom_layout.setContentsMargins(0, 0, 0, 0)
self.pull_up_bottom_layout.addWidget(self.pull_up_name, 50)
self.pull_up_bottom_layout.addWidget(self.pull_up_score, 50)
self.pull_up_layout = QVBoxLayout()
self.pull_up_layout.setContentsMargins(20, 0, 20, 0)
self.pull_up_layout.addWidget(self.pull_up_title, 50)
self.pull_up_layout.addLayout(self.pull_up_bottom_layout, 50)
self.pull_up_top.setLayout(self.pull_up_layout)
self.runaround_bottom_layout = QHBoxLayout()
self.runaround_bottom_layout.setContentsMargins(0, 0, 0, 0)
self.runaround_bottom_layout.addWidget(self.runaround_name, 50)
self.runaround_bottom_layout.addWidget(self.runaround_score, 50)
self.runaround_layout = QVBoxLayout()
self.runaround_layout.setContentsMargins(20, 0, 20, 0)
self.runaround_layout.addWidget(self.runaround_title, 50)
self.runaround_layout.addLayout(self.runaround_bottom_layout, 50)
self.runaround_top.setLayout(self.runaround_layout)
self.running_bottom_layout = QHBoxLayout()
self.running_bottom_layout.setContentsMargins(0, 0, 0, 0)
self.running_bottom_layout.addWidget(self.running_name, 50)
self.running_bottom_layout.addWidget(self.running_score, 50)
self.running_layout = QVBoxLayout()
self.running_layout.setContentsMargins(20, 0, 20, 0)
self.running_layout.addWidget(self.running_title, 50)
self.running_layout.addLayout(self.running_bottom_layout, 50)
self.running_top.setLayout(self.running_layout)
self.push_up_bottom_layout = QHBoxLayout()
self.push_up_bottom_layout.setContentsMargins(0, 0, 0, 0)
self.push_up_bottom_layout.addWidget(self.push_up_name, 50)
self.push_up_bottom_layout.addWidget(self.push_up_score, 50)
self.push_up_layout = QVBoxLayout()
self.push_up_layout.setContentsMargins(20, 0, 20, 0)
self.push_up_layout.addWidget(self.push_up_title, 50)
self.push_up_layout.addLayout(self.push_up_bottom_layout, 50)
self.push_up_top.setLayout(self.push_up_layout)
self.top_layout = QHBoxLayout()
self.top_layout.setContentsMargins(0, 0, 50, 0)
self.top_layout.addWidget(self.badge_widget, 17)
self.top_layout.addWidget(self.badge_label, 53)
self.top_layout.addWidget(self.top_one_widget, 30)
self.bottom_layout = QHBoxLayout()
self.bottom_layout.setContentsMargins(0, 0, 0, 0)
self.bottom_layout.addWidget(self.sit_up_top, 20)
self.bottom_layout.addWidget(self.pull_up_top, 20)
self.bottom_layout.addWidget(self.runaround_top, 20)
self.bottom_layout.addWidget(self.running_top, 20)
self.bottom_layout.addWidget(self.push_up_top, 20)
self.main_layout = QVBoxLayout()
self.main_layout.setContentsMargins(0, 0, 0, 0)
self.main_layout.addLayout(self.top_layout, 50)
self.main_layout.addLayout(self.bottom_layout, 50)
self.item_widget.setLayout(self.main_layout)
self.layout = QHBoxLayout()
self.layout.setContentsMargins(0, 0, 0, 0)
self.layout.addWidget(self.item_widget)
self.setLayout(self.layout)
def set_data(self, data):
if len(data['total']) > 0:
self.top_one_name.setText(data['total']['name'])
self.top_one_score.setText('(' + str(data['total']['score']) + '<EFBFBD><EFBFBD>)')
else:
self.top_one_name.setText('')
self.top_one_score.setText('<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
self.empty_label(self.top_one_score)
if len(data['situp']) > 0:
self.sit_up_name.setText(data['situp']['name'])
self.sit_up_score.setText('(' + str(data['situp']['score']) + '<EFBFBD><EFBFBD>)')
else:
self.sit_up_name.setText('')
self.sit_up_score.setText('<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
self.empty_label(self.sit_up_score)
if len(data['pullup']) > 0:
self.pull_up_name.setText(data['pullup']['name'])
self.pull_up_score.setText('(' + str(data['pullup']['score']) + '<EFBFBD><EFBFBD>)')
else:
self.pull_up_name.setText('')
self.pull_up_score.setText('<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
self.empty_label(self.pull_up_score)
if len(data['runaround']) > 0:
self.runaround_name.setText(data['runaround']['name'])
self.runaround_score.setText('(' + str(data['runaround']['score']) + '<EFBFBD><EFBFBD>)')
else:
self.runaround_name.setText('')
self.runaround_score.setText('<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
self.empty_label(self.runaround_score)
if len(data['running']) > 0:
self.running_name.setText(data['running']['name'])
self.running_score.setText('(' + str(data['running']['score']) + ')')
else:
self.running_name.setText('')
self.running_score.setText('<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
self.empty_label(self.running_score)
if len(data['pushup']) > 0:
self.push_up_name.setText(data['pushup']['name'])
self.push_up_score.setText('(' + str(data['pushup']['score']) + '<EFBFBD><EFBFBD>)')
else:
self.push_up_name.setText('')
self.push_up_score.setText('<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>')
self.empty_label(self.push_up_score)
def empty_label(self, empty_label):
empty_label.setAlignment(Qt.AlignCenter)
empty_label.setStyleSheet(
"color: #ffffff;"
"font: 600 20px \"Microsoft YaHei UI\";"
"background-color: none;"
"background: none;"
"border-image: none;"
"margin-bottom: 20px;"
"margin-right: 30px;"
)
@staticmethod
def _init_item_widget():
item_widget = QWidget()
item_widget.setStyleSheet(
"background-color: none;"
"border-radius: 4px;"
"background: none;"
)
return item_widget
@staticmethod
def _init_badge_widget():
badge_widget = QLabel()
badge_widget.setStyleSheet(
"border-image: url(assets/badge.png);"
"background-size: contain;"
"background-repeat: no-repeat;"
"background-position: center;"
"margin: 6px;"
)
return badge_widget
@staticmethod
def _init_badge_label():
badge_label = QLabel('<EFBFBD>й<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>װ<EFBFBD><EFBFBD><EFBFBD>첿<EFBFBD><EFBFBD>')
badge_label.setStyleSheet(
"color: #fcef24;"
"text-shadow: 1.5px 1.5px 0px #b78c0c;"
"letter-spacing: 4px;"
"font: 600 24px \"Microsoft YaHei UI\";"
)
return badge_label
@staticmethod
def _init_top_one_widget():
top_one_widget = QWidget()
top_one_widget.setStyleSheet(
"border-image: url(assets/top_bg.png);"
"background-size: contain;"
"background-repeat: no-repeat;"
"background-position: center;"
"background: none;"
"border: none;"
"background-color: none;"
)
return top_one_widget
@staticmethod
def _init_top_one_title():
top_one_title = QLabel('<EFBFBD>ֵܷ<EFBFBD>һ<EFBFBD><EFBFBD>')
top_one_title.setAlignment(Qt.AlignCenter)
top_one_title.setStyleSheet(
"color: #ffffff;"
"font: 600 26px \"Microsoft YaHei UI\";"
"background-color: none;"
"background: none;"
"border-image: none;"
"margin-top: 20px;"
)
return top_one_title
@staticmethod
def _init_top_one_name():
top_one_name = QLabel()
top_one_name.setAlignment(Qt.AlignCenter)
top_one_name.setStyleSheet(
"color: #08a4ff;"
"font: 600 24px \"Microsoft YaHei UI\";"
"background-color: none;"
"background: none;"
"border-image: none;"
"margin-bottom: 20px;"
)
return top_one_name
@staticmethod
def _init_top_one_score():
top_one_score = QLabel()
top_one_score.setAlignment(Qt.AlignCenter)
top_one_score.setStyleSheet(
"color: #ffffff;"
"font: 600 24px \"Microsoft YaHei UI\";"
"background-color: none;"
"background: none;"
"border-image: none;"
"margin-bottom: 20px;"
)
return top_one_score
@staticmethod
def _init_test_one_title():
test_one_title = QLabel()
test_one_title.setAlignment(Qt.AlignCenter)
test_one_title.setStyleSheet(
"color: #ffffff;"
"font: 600 17px \"Microsoft YaHei UI\";"
"background-color: none;"
"background: none;"
"border-image: none;"
"margin-top: 20px;"
)
return test_one_title
@staticmethod
def _init_test_one_name():
test_one_name = QLabel()
test_one_name.setAlignment(Qt.AlignCenter)
test_one_name.setStyleSheet(
"color: #ffffff;"
"font: 600 19px \"Microsoft YaHei UI\";"
"background-color: none;"
"background: none;"
"border-image: none;"
"margin-bottom: 20px;"
"color: #08a4ff;"
)
return test_one_name
@staticmethod
def _init_test_one_score():
test_one_score = QLabel()
test_one_score.setAlignment(Qt.AlignCenter)
test_one_score.setStyleSheet(
"color: #ffffff;"
"font: 600 17px \"Microsoft YaHei UI\";"
"background-color: none;"
"background: none;"
"border-image: none;"
"margin-bottom: 20px;"
)
return test_one_score
@staticmethod
def init_table_stacked_widget():
table_stacked_widget = QStackedWidget()
table_stacked_widget.setStyleSheet(
"background: transparent;"
"border: none;"
"border-image: none;"
)
return table_stacked_widget