WeChatMsg/app/Ui/contact/report/report.py

75 lines
2.5 KiB
Python
Raw Normal View History

2023-05-20 23:55:21 +08:00
import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtWidgets import *
2023-11-11 18:58:40 +08:00
from app import person
from app.DataBase import data
from . import annual_report
2023-05-20 23:55:21 +08:00
class ReportController(QWidget):
2023-11-11 18:58:40 +08:00
def __init__(self, contact: person.Contact, me: person.Me = None, parent=None):
2023-05-20 23:55:21 +08:00
super().__init__(parent)
2023-11-11 18:58:40 +08:00
self.ta_username = contact.wxid
self.contact = contact
self.Me = me
2023-05-20 23:55:21 +08:00
# self.setStyleSheet('''QWidget{background-color:rgb(240, 240, 240);}''')
# 加载动画
self.center()
self.label_01()
def center(self): # 定义一个函数使得窗口居中显示
# 获取屏幕坐标系
screen = QDesktopWidget().screenGeometry()
# 获取窗口坐标系
size = self.geometry()
newLeft = (screen.width() - size.width()) / 2
newTop = (screen.height() - size.height()) / 2
self.move(int(newLeft), int(newTop))
def label_01(self):
w = self.size().width()
h = self.size().height()
self.label = QLabel(self)
self.label.setGeometry(w // 2, h // 2, 100, 100)
self.label.setToolTip("这是一个标签")
# self.m_movie()
self.initUI()
def m_movie(self):
movie = QMovie("./app/data/bg.gif")
self.label.setMovie(movie)
movie.start()
def initUI(self):
2023-11-11 18:58:40 +08:00
start_time = data.get_msg_start_time(self.contact.wxid)
annual_report.create_title_page(self.contact.nickname, start_time, self.contact.avatar_path)
2023-05-20 23:55:21 +08:00
self.label.setVisible(False)
# self.setStyleSheet('''QWidget{background-color:rgb(244, 244, 244);}''')
main_box = QHBoxLayout(self)
self.browser1 = QWebEngineView()
self.browser1.load(QUrl('file:///data/AnnualReport/index.html'))
splitter1 = QSplitter(Qt.Vertical)
splitter1.addWidget(self.browser1)
main_box.addWidget(splitter1)
self.setLayout(main_box)
def setBackground(self):
palette = QPalette()
pix = QPixmap("./app/data/bg.png")
pix = pix.scaled(self.width(), self.height(), Qt.IgnoreAspectRatio, Qt.SmoothTransformation) # 自适应图片大小
palette.setBrush(self.backgroundRole(), QBrush(pix)) # 设置背景图片
# palette.setColor(self.backgroundRole(), QColor(192, 253, 123)) # 设置背景颜色
self.setPalette(palette)
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = ReportController(1)
ex.show()
sys.exit(app.exec_())