From 19d529c36e9686889f9813d6afd6939c2909697f Mon Sep 17 00:00:00 2001 From: shuaikangzhou <863909694@qq.com> Date: Sun, 2 Apr 2023 21:23:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AF=B9=E8=AF=9D=E6=83=85?= =?UTF-8?q?=E6=84=9F=E5=88=86=E6=9E=90=EF=BC=8C=E5=A2=9E=E5=8A=A0=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E8=87=AA=E9=80=82=E5=BA=94=EF=BC=8C=E6=96=B0=E5=A2=9E?= =?UTF-8?q?emotion=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TEST.py | 46 +-- TEST/mainwindow.ui | 103 +++++ app/DataBase/data.py | 38 +- app/DataBase/output.py | 9 +- app/Ui/123.py | 5 + app/Ui/chat/chat.py | 67 +-- app/Ui/chat/chatUi.py | 228 ++++++----- app/Ui/chat/chatUi.ui | 613 ++++++++++++++-------------- app/Ui/contact/analysis/analysis.py | 10 +- app/Ui/contact/analysis/charts.py | 6 +- app/Ui/contact/contact.py | 113 ++++- app/Ui/contact/contactUi.py | 64 ++- app/Ui/contact/contactUi.ui | 425 ++++++++++--------- app/Ui/contact/emotion/__init__.py | 0 app/Ui/contact/emotion/emotionUi.ui | 19 + app/Ui/mainview.py | 20 +- app/Ui/mainviewUi.py | 43 +- app/Ui/mainviewUi.ui | 69 ++-- app/Ui/mainwindow.ui | 251 ++++++++++++ main.py | 12 +- test.html | 149 ------- wechat.html | 55 --- 22 files changed, 1351 insertions(+), 994 deletions(-) create mode 100644 TEST/mainwindow.ui create mode 100644 app/Ui/123.py create mode 100644 app/Ui/contact/emotion/__init__.py create mode 100644 app/Ui/contact/emotion/emotionUi.ui create mode 100644 app/Ui/mainwindow.ui delete mode 100644 test.html delete mode 100644 wechat.html diff --git a/TEST.py b/TEST.py index 43c5642..a03d1e8 100644 --- a/TEST.py +++ b/TEST.py @@ -1,40 +1,8 @@ -import json +from snownlp import SnowNLP -from pyecharts import options as opts -from pyecharts.charts import Graph - -with open(r'data/npmdepgraph.min10.json', 'r') as f: - data = json.load(f) - -nodes = [ - { - 'x': node['x'], - 'y': node['y'], - 'name': node['label'], - 'symbolSize': node['size'], - 'itemStyle': {'color': node['color']} - } - for node in data['nodes'] -] - -edges = [ - { - 'source': edge['sourceID'], - 'target': edge['targetID'] - } - for edge in data['edges'] -] - -G = Graph(init_opts=opts.InitOpts(width='900', height='900')) -G.add( - series_name='', - nodes=nodes, - links=edges, - layout='none', - is_roam=True, - is_focusnode=True, - label_opts=opts.LabelOpts(is_show=True), - linestyle_opts=opts.LineStyleOpts(width=0.5, curve=0.3, opacity=0.7) -) -G.set_global_opts(title_opts=opts.TitleOpts(title='NPM Dependencies')) -G.render('npm_dependencies.html') +# 文本 +text = u'🙄”' +# 分析 +s = SnowNLP(text) +# 输出情绪为积极的概率 +print(s) diff --git a/TEST/mainwindow.ui b/TEST/mainwindow.ui new file mode 100644 index 0000000..b559bba --- /dev/null +++ b/TEST/mainwindow.ui @@ -0,0 +1,103 @@ + + + MainWindow + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 30 + 20 + + + + + + + + PushButton + + + + + + + PushButton + + + + + + + Qt::Horizontal + + + + 29 + 20 + + + + + + + + + + + + 0 + 0 + 800 + 23 + + + + + 你好 + + + + + OK + + + + + + + + + + diff --git a/app/DataBase/data.py b/app/DataBase/data.py index e21eb3a..c26d4ed 100644 --- a/app/DataBase/data.py +++ b/app/DataBase/data.py @@ -200,13 +200,25 @@ def get_message(wxid, num): sql = ''' select * from message where talker = ? - order by msgId desc + order by createTime desc limit ?,100 ''' cursor.execute(sql, [wxid, num * 100]) return cursor.fetchall() +def get_text_by_num(wxid, num): + sql = ''' + SELECT content,strftime('%Y-%m-%d',createTime/1000,'unixepoch','localtime') as days + from message + where talker = ? and type=1 + order by days + ''' + '''group by days''' + cursor.execute(sql, [wxid]) + return cursor.fetchall() + + def search_send_message(start_time, end_time): start_time = '2022-1-1 00:00:00' end_time = '2023-1-1 00:00:00' @@ -261,7 +273,7 @@ def get_emoji(imgPath): except sqlite3.ProgrammingError as e: print(e, imgPath) return False - return newPath + return False def download_emoji(imgPath, url): @@ -654,6 +666,12 @@ def chat_start_endTime(username): print(year, month, day, hour, minute, second) +if __name__ == '__main__': + wxid = 'wxid_8piw6sb4hvfm22' + wxid = 'wxid_wt2vsktnu4z022' + # emotion_analysis(wxid) + plot_emotion(wxid) +''' if __name__ == '__main__': # rconversation = get_rconversation() # for i in rconversation: @@ -680,5 +698,17 @@ if __name__ == '__main__': # print(result) # radar_hour('wxid_8piw6sb4hvfm22') # print(result) - print(get_msg_start_time('wxid_8piw6sb4hvfm22'), get_msg_end_time('wxid_8piw6sb4hvfm22')) - chat_start_endTime('wxid_8piw6sb4hvfm22') + # print(get_msg_start_time('wxid_8piw6sb4hvfm22'), get_msg_end_time('wxid_8piw6sb4hvfm22')) + # chat_start_endTime('wxid_8piw6sb4hvfm22') + msg = get_text_by_num('wxid_8piw6sb4hvfm22', 1) + from snownlp import SnowNLP + + # print(msg[0]) + for m in msg: + content = m[0] + print(content) + s = SnowNLP(content) + # # 输出情绪为积极的概率 + print(s.sentiments) + # print(msg) +''' diff --git a/app/DataBase/output.py b/app/DataBase/output.py index dbead37..b7fc98a 100644 --- a/app/DataBase/output.py +++ b/app/DataBase/output.py @@ -14,11 +14,11 @@ from . import data def IS_5_min(last_m, now_m): - ''' + """ #! 判断两次聊天时间是不是大于五分钟 #! 若大于五分钟则显示时间 #! 否则不显示 - ''' + """ '''两次聊天记录时间差,单位是秒''' dt = now_m - last_m return abs(dt // 1000) >= 300 @@ -55,7 +55,6 @@ class Output(QThread): def merge_docx(self, conRemark, n): origin_docx_path = f"{os.path.abspath('.')}/data/聊天记录/{conRemark}" - all_word = os.listdir(origin_docx_path) all_file_path = [] for i in range(n): file_name = f"{conRemark}{i}.docx" @@ -295,14 +294,14 @@ class ChildThread(QThread): doc.add_paragraph() def pat_a_pat(self, doc, isSend, content, status): - ''' + """ #! 添加拍一拍信息 todo 把wxid转化成昵称 :param isSend: :param content: :param status: :return: - ''' + """ try: pat_data = xmltodict.parse(content) pat_data = pat_data['msg']['appmsg']['patMsg']['records']['record'] diff --git a/app/Ui/123.py b/app/Ui/123.py new file mode 100644 index 0000000..270793a --- /dev/null +++ b/app/Ui/123.py @@ -0,0 +1,5 @@ +# This Python file uses the following encoding: utf-8 + +# if __name__ == "__main__": +# pass +print('hello') diff --git a/app/Ui/chat/chat.py b/app/Ui/chat/chat.py index 3ee31d3..7b89816 100644 --- a/app/Ui/chat/chat.py +++ b/app/Ui/chat/chat.py @@ -21,7 +21,7 @@ from ...DataBase import data from ...ImageBox.ui import MainDemo -class ChatController(QWidget, Ui_Dialog): +class ChatController(QWidget, Ui_Form): exitSignal = pyqtSignal() urlSignal = pyqtSignal(QUrl) @@ -32,6 +32,11 @@ class ChatController(QWidget, Ui_Dialog): self.chatroomFlag = None self.ta_avatar = None self.setupUi(self) + self.message = self.message_2 + self.frame = self.frame_2 + self.scrollAreaWidgetContents = self.scrollAreaWidgetContents_2 + self.label_remark = self.label_remark_2 + self.textEdit = self.textEdit_2 self.setWindowTitle('WeChat') self.setWindowIcon(QIcon('./app/data/icon.png')) self.initui() @@ -43,6 +48,7 @@ class ChatController(QWidget, Ui_Dialog): self.last_btn = None self.chat_flag = True # self.showChat() + self.message.verticalScrollBar().valueChanged.connect(self.textbrower_verticalScrollBar) self.show_flag = False self.ta_username = None @@ -59,29 +65,29 @@ class ChatController(QWidget, Ui_Dialog): self.message.setOpenExternalLinks(False) # self.message.anchorClicked(self.hyperlink()) self.message.anchorClicked.connect(self.hyperlink) - self.btn_sendMsg = QtWidgets.QPushButton(self.frame) - self.btn_sendMsg.setGeometry(QtCore.QRect(680, 670, 121, 51)) - font = QtGui.QFont() - font.setFamily("黑体") - font.setPointSize(15) - font.setBold(False) - font.setWeight(50) - self.btn_sendMsg.setFont(font) - self.btn_sendMsg.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor)) - self.btn_sendMsg.setMouseTracking(False) - self.btn_sendMsg.setAutoFillBackground(False) - self.btn_sendMsg.setStyleSheet("QPushButton {background-color: #f0f0f0;\n" - "padding: 10px;\n" - "color:rgb(5,180,104);}\n" - "QPushButton:hover{background-color: rgb(198,198,198)}\n" - ) - self.btn_sendMsg.setIconSize(QtCore.QSize(40, 40)) - self.btn_sendMsg.setCheckable(False) - self.btn_sendMsg.setAutoDefault(True) - self.btn_sendMsg.setObjectName("btn_sendMsg") - _translate = QtCore.QCoreApplication.translate - self.btn_sendMsg.setText(_translate("Dialog", "发送")) - self.btn_sendMsg.setToolTip('按Enter键发送,按Ctrl+Enter键换行') + # self.btn_sendMsg = QtWidgets.QPushButton(self.textEdit) + # self.btn_sendMsg.setGeometry(QtCore.QRect(1, 1, 121, 51)) + # font = QtGui.QFont() + # font.setFamily("黑体") + # font.setPointSize(15) + # font.setBold(False) + # font.setWeight(50) + # self.btn_sendMsg.setFont(font) + # self.btn_sendMsg.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor)) + # self.btn_sendMsg.setMouseTracking(False) + # self.btn_sendMsg.setAutoFillBackground(False) + # self.btn_sendMsg.setStyleSheet("QPushButton {background-color: #f0f0f0;\n" + # "padding: 10px;\n" + # "color:rgb(5,180,104);}\n" + # "QPushButton:hover{background-color: rgb(198,198,198)}\n" + # ) + # self.btn_sendMsg.setIconSize(QtCore.QSize(40, 40)) + # self.btn_sendMsg.setCheckable(False) + # self.btn_sendMsg.setAutoDefault(True) + # self.btn_sendMsg.setObjectName("btn_sendMsg") + # _translate = QtCore.QCoreApplication.translate + # self.btn_sendMsg.setText(_translate("Dialog", "发送")) + self.btn_sendMsg_2.setToolTip('按Enter键发送,按Ctrl+Enter键换行') def showChat(self): """ @@ -92,7 +98,9 @@ class ChatController(QWidget, Ui_Dialog): return self.show_flag = True rconversations = data.get_rconversation() - max_hight = max(len(rconversations) * 80, 680) + # max_hight = max(len(rconversations) * 80, 680) + max_hight = max(len(rconversations) * 80, self.size().height()) + self.scrollAreaWidgetContents.setGeometry( QtCore.QRect(0, 0, 300, max_hight)) for i in range(len(rconversations)): @@ -117,8 +125,8 @@ class ChatController(QWidget, Ui_Dialog): if self.last_talkerId and self.last_talkerId != talkerId: print('对方账号:', self.last_talkerId) self.contacts[self.last_talkerId].setStyleSheet( - "QPushButton {background-color: rgb(253,253,253);}" - "QPushButton:hover{background-color: rgb(209,209,209);}\n" + "QPushButton {background-color: rgb(220,220,220);}" + "QPushButton:hover{background-color: rgb(208,208,208);}\n" ) self.last_talkerId = talkerId self.contacts[talkerId].setStyleSheet( @@ -264,6 +272,7 @@ class ChatController(QWidget, Ui_Dialog): def show_emoji(self, isSend, imagePath, content): imgPath = data.get_emoji(imagePath) + print('emoji:', imgPath) if not imgPath: return False image = Image.open(imgPath) @@ -496,8 +505,8 @@ class Contact(QtWidgets.QPushButton): self.gridLayout1.setRowStretch(1, 3) self.setLayout(self.gridLayout1) self.setStyleSheet( - "QPushButton {background-color: rgb(253,253,253);}" - "QPushButton:hover{background-color: rgb(209,209,209);}\n" + "QPushButton {background-color: rgb(220,220,220);}" + "QPushButton:hover{background-color: rgb(208,208,208);}\n" ) self.msgCount = contact[0] self.username = contact[1] diff --git a/app/Ui/chat/chatUi.py b/app/Ui/chat/chatUi.py index f5e2413..dc01f31 100644 --- a/app/Ui/chat/chatUi.py +++ b/app/Ui/chat/chatUi.py @@ -11,120 +11,140 @@ from PyQt5 import QtCore, QtGui, QtWidgets -class Ui_Dialog(object): - def setupUi(self, Dialog): - Dialog.setObjectName("Dialog") - Dialog.resize(1120, 720) - Dialog.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor)) - Dialog.setAutoFillBackground(False) - self.frame_2 = QtWidgets.QFrame(Dialog) - self.frame_2.setGeometry(QtCore.QRect(0, 0, 1120, 720)) +class Ui_Form(object): + def setupUi(self, Form): + Form.setObjectName("Form") + Form.resize(878, 720) + self.horizontalLayout = QtWidgets.QHBoxLayout(Form) + self.horizontalLayout.setObjectName("horizontalLayout") + self.scrollArea_2 = QtWidgets.QScrollArea(Form) + self.scrollArea_2.setEnabled(True) + self.scrollArea_2.setMaximumSize(QtCore.QSize(325, 150000)) + self.scrollArea_2.setAutoFillBackground(False) + self.scrollArea_2.setFrameShape(QtWidgets.QFrame.WinPanel) + self.scrollArea_2.setFrameShadow(QtWidgets.QFrame.Raised) + self.scrollArea_2.setMidLineWidth(0) + self.scrollArea_2.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) + self.scrollArea_2.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) + self.scrollArea_2.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContentsOnFirstShow) + self.scrollArea_2.setWidgetResizable(False) + self.scrollArea_2.setObjectName("scrollArea_2") + self.scrollAreaWidgetContents_2 = QtWidgets.QWidget() + self.scrollAreaWidgetContents_2.setGeometry(QtCore.QRect(0, 0, 300, 12000)) + self.scrollAreaWidgetContents_2.setObjectName("scrollAreaWidgetContents_2") + self.pushButton_3 = QtWidgets.QPushButton(self.scrollAreaWidgetContents_2) + self.pushButton_3.setGeometry(QtCore.QRect(0, 0, 300, 80)) + self.pushButton_3.setLayoutDirection(QtCore.Qt.LeftToRight) + self.pushButton_3.setAutoFillBackground(False) + self.pushButton_3.setText("") + self.pushButton_3.setIconSize(QtCore.QSize(80, 80)) + self.pushButton_3.setObjectName("pushButton_3") + self.label_2 = QtWidgets.QLabel(self.scrollAreaWidgetContents_2) + self.label_2.setGeometry(QtCore.QRect(220, 10, 72, 15)) + self.label_2.setObjectName("label_2") + self.scrollArea_2.setWidget(self.scrollAreaWidgetContents_2) + self.horizontalLayout.addWidget(self.scrollArea_2) + self.frame_2 = QtWidgets.QFrame(Form) + self.frame_2.setMinimumSize(QtCore.QSize(500, 500)) + self.frame_2.setStyleSheet("background-color: #F5F5F5;") self.frame_2.setFrameShape(QtWidgets.QFrame.StyledPanel) self.frame_2.setFrameShadow(QtWidgets.QFrame.Raised) self.frame_2.setObjectName("frame_2") - self.scrollArea = QtWidgets.QScrollArea(self.frame_2) - self.scrollArea.setEnabled(True) - self.scrollArea.setGeometry(QtCore.QRect(0, 40, 326, 680)) - self.scrollArea.setMaximumSize(QtCore.QSize(400, 150000)) - self.scrollArea.setAutoFillBackground(False) - self.scrollArea.setFrameShape(QtWidgets.QFrame.WinPanel) - self.scrollArea.setFrameShadow(QtWidgets.QFrame.Raised) - self.scrollArea.setMidLineWidth(0) - self.scrollArea.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) - self.scrollArea.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) - self.scrollArea.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContentsOnFirstShow) - self.scrollArea.setWidgetResizable(False) - self.scrollArea.setObjectName("scrollArea") - self.scrollAreaWidgetContents = QtWidgets.QWidget() - self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 300, 12000)) - self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents") - self.pushButton_2 = QtWidgets.QPushButton(self.scrollAreaWidgetContents) - self.pushButton_2.setGeometry(QtCore.QRect(0, 0, 300, 80)) - self.pushButton_2.setLayoutDirection(QtCore.Qt.LeftToRight) - self.pushButton_2.setAutoFillBackground(False) - self.pushButton_2.setText("") - self.pushButton_2.setIconSize(QtCore.QSize(80, 80)) - self.pushButton_2.setObjectName("pushButton_2") - self.label = QtWidgets.QLabel(self.scrollAreaWidgetContents) - self.label.setGeometry(QtCore.QRect(220, 10, 72, 15)) - self.label.setObjectName("label") - self.scrollArea.setWidget(self.scrollAreaWidgetContents) - self.frame = QtWidgets.QFrame(self.frame_2) - self.frame.setGeometry(QtCore.QRect(321, 0, 801, 720)) - self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel) - self.frame.setFrameShadow(QtWidgets.QFrame.Raised) - self.frame.setObjectName("frame") - self.message = QtWidgets.QTextBrowser(self.frame) - self.message.setGeometry(QtCore.QRect(9, 39, 801, 541)) - self.message.setStyleSheet("background-color: #F5F5F5;") - self.message.setObjectName("message") - self.textEdit = QtWidgets.QTextEdit(self.frame) - self.textEdit.setGeometry(QtCore.QRect(9, 579, 821, 141)) + self.verticalLayout = QtWidgets.QVBoxLayout(self.frame_2) + self.verticalLayout.setContentsMargins(0, 5, 0, 0) + self.verticalLayout.setObjectName("verticalLayout") + self.horizontalLayout_3 = QtWidgets.QHBoxLayout() + self.horizontalLayout_3.setObjectName("horizontalLayout_3") + self.label_remark_2 = QtWidgets.QLabel(self.frame_2) + font = QtGui.QFont() + font.setPointSize(12) + self.label_remark_2.setFont(font) + self.label_remark_2.setText("") + self.label_remark_2.setObjectName("label_remark_2") + self.horizontalLayout_3.addWidget(self.label_remark_2) + spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) + self.horizontalLayout_3.addItem(spacerItem) + self.toolButton_2 = QtWidgets.QToolButton(self.frame_2) + self.toolButton_2.setObjectName("toolButton_2") + self.horizontalLayout_3.addWidget(self.toolButton_2) + self.verticalLayout.addLayout(self.horizontalLayout_3) + self.line_5 = QtWidgets.QFrame(self.frame_2) + self.line_5.setFrameShape(QtWidgets.QFrame.HLine) + self.line_5.setFrameShadow(QtWidgets.QFrame.Sunken) + self.line_5.setObjectName("line_5") + self.verticalLayout.addWidget(self.line_5) + self.message_2 = QtWidgets.QTextBrowser(self.frame_2) + self.message_2.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) + self.message_2.setStyleSheet("background-color: #F5F5F5;") + self.message_2.setObjectName("message_2") + self.verticalLayout.addWidget(self.message_2) + self.line_6 = QtWidgets.QFrame(self.frame_2) + self.line_6.setFrameShape(QtWidgets.QFrame.HLine) + self.line_6.setFrameShadow(QtWidgets.QFrame.Sunken) + self.line_6.setObjectName("line_6") + self.verticalLayout.addWidget(self.line_6) + self.textEdit_2 = QtWidgets.QTextEdit(self.frame_2) font = QtGui.QFont() font.setPointSize(15) - self.textEdit.setFont(font) - self.textEdit.setTabStopWidth(80) - self.textEdit.setCursorWidth(1) - self.textEdit.setObjectName("textEdit") - self.btn_sendMsg = QtWidgets.QPushButton(self.frame) - self.btn_sendMsg.setGeometry(QtCore.QRect(680, 670, 121, 51)) + self.textEdit_2.setFont(font) + self.textEdit_2.setAutoFillBackground(False) + self.textEdit_2.setStyleSheet("background-color: #F5F5F5;") + self.textEdit_2.setFrameShape(QtWidgets.QFrame.NoFrame) + self.textEdit_2.setOverwriteMode(False) + self.textEdit_2.setTabStopWidth(80) + self.textEdit_2.setAcceptRichText(True) + self.textEdit_2.setCursorWidth(1) + self.textEdit_2.setTextInteractionFlags(QtCore.Qt.TextEditorInteraction) + self.textEdit_2.setObjectName("textEdit_2") + self.verticalLayout.addWidget(self.textEdit_2) + self.horizontalLayout_2 = QtWidgets.QHBoxLayout() + self.horizontalLayout_2.setObjectName("horizontalLayout_2") + spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) + self.horizontalLayout_2.addItem(spacerItem1) + self.btn_sendMsg_2 = QtWidgets.QPushButton(self.frame_2) font = QtGui.QFont() font.setFamily("黑体") font.setPointSize(15) font.setBold(False) font.setWeight(50) - self.btn_sendMsg.setFont(font) - self.btn_sendMsg.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor)) - self.btn_sendMsg.setMouseTracking(False) - self.btn_sendMsg.setAutoFillBackground(False) - self.btn_sendMsg.setStyleSheet("QPushButton {\n" -" background-color: #f0f0f0;\n" -" \n" -" padding: 10px;\n" -" color:rgb(5,180,104);\n" -"}") - self.btn_sendMsg.setIconSize(QtCore.QSize(40, 40)) - self.btn_sendMsg.setCheckable(False) - self.btn_sendMsg.setAutoDefault(True) - self.btn_sendMsg.setObjectName("btn_sendMsg") - self.toolButton = QtWidgets.QToolButton(self.frame) - self.toolButton.setGeometry(QtCore.QRect(760, 0, 47, 41)) - self.toolButton.setObjectName("toolButton") - self.line_3 = QtWidgets.QFrame(self.frame) - self.line_3.setGeometry(QtCore.QRect(2, 0, 3, 720)) - self.line_3.setLineWidth(6) - self.line_3.setFrameShape(QtWidgets.QFrame.VLine) - self.line_3.setFrameShadow(QtWidgets.QFrame.Sunken) - self.line_3.setObjectName("line_3") - self.line_2 = QtWidgets.QFrame(self.frame) - self.line_2.setGeometry(QtCore.QRect(9, 30, 831, 20)) - self.line_2.setFrameShape(QtWidgets.QFrame.HLine) - self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken) - self.line_2.setObjectName("line_2") - self.label_remark = QtWidgets.QLabel(self.frame) - self.label_remark.setGeometry(QtCore.QRect(30, 0, 351, 41)) - font = QtGui.QFont() - font.setPointSize(12) - self.label_remark.setFont(font) - self.label_remark.setText("") - self.label_remark.setObjectName("label_remark") - self.line = QtWidgets.QFrame(self.frame) - self.line.setGeometry(QtCore.QRect(20, 580, 800, 3)) - self.line.setFrameShape(QtWidgets.QFrame.HLine) - self.line.setFrameShadow(QtWidgets.QFrame.Sunken) - self.line.setObjectName("line") + self.btn_sendMsg_2.setFont(font) + self.btn_sendMsg_2.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor)) + self.btn_sendMsg_2.setMouseTracking(False) + self.btn_sendMsg_2.setAutoFillBackground(False) + self.btn_sendMsg_2.setStyleSheet("QPushButton {\n" + "background-color:rgb(233,233,233);\n" + "padding: 10px;\n" + "color:rgb(5,180,104);}\n" + "QPushButton:hover{\n" + "background-color:rgb(198,198,198)}") + self.btn_sendMsg_2.setIconSize(QtCore.QSize(40, 40)) + self.btn_sendMsg_2.setCheckable(False) + self.btn_sendMsg_2.setAutoDefault(True) + self.btn_sendMsg_2.setObjectName("btn_sendMsg_2") + self.horizontalLayout_2.addWidget(self.btn_sendMsg_2) + self.horizontalLayout_2.setStretch(0, 7) + self.horizontalLayout_2.setStretch(1, 2) + self.verticalLayout.addLayout(self.horizontalLayout_2) + self.verticalLayout.setStretch(0, 2) + self.verticalLayout.setStretch(1, 2) + self.verticalLayout.setStretch(2, 60) + self.verticalLayout.setStretch(3, 2) + self.verticalLayout.setStretch(4, 2) + self.verticalLayout.setStretch(5, 1) + self.horizontalLayout.addWidget(self.frame_2) - self.retranslateUi(Dialog) - QtCore.QMetaObject.connectSlotsByName(Dialog) + self.retranslateUi(Form) + QtCore.QMetaObject.connectSlotsByName(Form) - def retranslateUi(self, Dialog): + def retranslateUi(self, Form): _translate = QtCore.QCoreApplication.translate - Dialog.setWindowTitle(_translate("Dialog", "Dialog")) - self.label.setText(_translate("Dialog", "TextLabel")) - self.textEdit.setHtml(_translate("Dialog", "\n" -"\n" -"


")) - self.btn_sendMsg.setText(_translate("Dialog", "发送")) - self.toolButton.setText(_translate("Dialog", "...")) + Form.setWindowTitle(_translate("Form", "Form")) + self.label_2.setText(_translate("Form", "TextLabel")) + self.toolButton_2.setText(_translate("Form", "...")) + self.textEdit_2.setHtml(_translate("Form", + "\n" + "\n" + "


")) + self.btn_sendMsg_2.setText(_translate("Form", "发送")) diff --git a/app/Ui/chat/chatUi.ui b/app/Ui/chat/chatUi.ui index a8de3c9..c7c2d3b 100644 --- a/app/Ui/chat/chatUi.ui +++ b/app/Ui/chat/chatUi.ui @@ -1,315 +1,306 @@ - Dialog - - - - 0 - 0 - 1120 - 720 - - - - ArrowCursor - - - Dialog - - - false - - - - - 0 - 0 - 1120 - 720 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - true - - - - 0 - 40 - 326 - 680 - - - - - 400 - 150000 - - - - false - - - QFrame::WinPanel - - - QFrame::Raised - - - 0 - - - Qt::ScrollBarAlwaysOn - - - Qt::ScrollBarAlwaysOff - - - QAbstractScrollArea::AdjustToContentsOnFirstShow - - - false - - - - - 0 - 0 - 300 - 12000 - - - - - - 0 - 0 - 300 - 80 - - - - Qt::LeftToRight - - - false - - - - - - - 80 - 80 - - - - - - - 220 - 10 - 72 - 15 - - - - TextLabel - - + Form + + + + 0 + 0 + 878 + 720 + + + + Form + + + + + + true + + + + 325 + 150000 + + + + false + + + QFrame::WinPanel + + + QFrame::Raised + + + 0 + + + Qt::ScrollBarAlwaysOn + + + Qt::ScrollBarAlwaysOff + + + QAbstractScrollArea::AdjustToContentsOnFirstShow + + + false + + + + + 0 + 0 + 300 + 12000 + + + + + + 0 + 0 + 300 + 80 + + + + Qt::LeftToRight + + + false + + + + + + + 80 + 80 + + + + + + + 220 + 10 + 72 + 15 + + + + TextLabel + + + + + + + + + + 500 + 500 + + + + background-color: #F5F5F5; + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 5 + + + 0 + + + 0 + + + + + + + + 12 + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + ... + + + + + + + + + Qt::Horizontal + + + + + + + Qt::ActionsContextMenu + + + background-color: #F5F5F5; + + + + + + + Qt::Horizontal + + + + + + + + 15 + + + + false + + + background-color: #F5F5F5; + + + QFrame::NoFrame + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> + <html><head><meta name="qrichtext" content="1" + /><style type="text/css"> + p, li { white-space: pre-wrap; } + </style></head><body style=" font-family:'SimSun'; + font-size:15pt; font-weight:400; font-style:normal;"> + <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; + margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br + /></p></body></html> + + + + false + + + 80 + + + true + + + 1 + + + Qt::TextEditorInteraction + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 黑体 + 15 + 50 + false + + + + ArrowCursor + + + false + + + false + + + QPushButton { + background-color:rgb(233,233,233); + padding: 10px; + color:rgb(5,180,104);} + QPushButton:hover{ + background-color:rgb(198,198,198)} + + + + 发送 + + + + 40 + 40 + + + + false + + + true + + + + + + + + + - - - - - 321 - 0 - 801 - 720 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - 9 - 39 - 801 - 541 - - - - Qt::ActionsContextMenu - - - background-color: #F5F5F5; - - - - - - 9 - 579 - 821 - 141 - - - - - 15 - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'SimSun'; font-size:15pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> - - - 80 - - - 1 - - - - - - 680 - 670 - 121 - 51 - - - - - 黑体 - 15 - 50 - false - - - - ArrowCursor - - - false - - - false - - - QPushButton { - background-color: #f0f0f0; - - padding: 10px; - color:rgb(5,180,104); -} - - - 发送 - - - - 40 - 40 - - - - false - - - true - - - - - - 760 - 0 - 47 - 41 - - - - ... - - - - - - 2 - 0 - 3 - 720 - - - - 6 - - - Qt::Vertical - - - - - - 9 - 30 - 831 - 20 - - - - Qt::Horizontal - - - - - - 30 - 0 - 351 - 41 - - - - - 12 - - - - - - - - - - 20 - 580 - 800 - 3 - - - - Qt::Horizontal - - - - - - - + + diff --git a/app/Ui/contact/analysis/analysis.py b/app/Ui/contact/analysis/analysis.py index ea9d3da..3fd4f5d 100644 --- a/app/Ui/contact/analysis/analysis.py +++ b/app/Ui/contact/analysis/analysis.py @@ -5,19 +5,20 @@ from PyQt5.QtGui import * from PyQt5.QtWebEngineWidgets import QWebEngineView from PyQt5.QtWidgets import * +QCoreApplication.setAttribute(Qt.AA_UseSoftwareOpenGL) from . import charts class AnalysisController(QWidget): - def __init__(self, username): - super().__init__() + def __init__(self, username, parent=None): + super().__init__(parent) self.ta_username = username self.setWindowTitle('数据分析') self.setWindowIcon(QIcon('./app/data/icon.png')) # self.setWindowFlag(Qt.FramelessWindowHint) - # self.setStyleSheet('''QWidget{background-color:rgb(255, 255, 255);}''') + self.setStyleSheet('''QWidget{background-color:rgb(255, 255, 255);}''') # self.setBackground() - self.resize(400, 300) + # self.resize(400, 300) self.center() self.setAttribute(Qt.WA_AttributeCount) self.label_01() @@ -47,6 +48,7 @@ class AnalysisController(QWidget): def initUI(self): 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/聊天统计/title.html')) diff --git a/app/Ui/contact/analysis/charts.py b/app/Ui/contact/analysis/charts.py index 48ca2cf..805aee9 100644 --- a/app/Ui/contact/analysis/charts.py +++ b/app/Ui/contact/analysis/charts.py @@ -286,7 +286,8 @@ def sport(username): .set_global_opts( title_opts=opts.TitleOpts(title="{}月".format(months[i + 1].strftime("%Y-%m"))), # legend_opts=opts.LegendOpts(is_show=False), - yaxis_opts=opts.AxisOpts(is_inverse=True) + yaxis_opts=opts.AxisOpts(is_inverse=True), + # xaxis_opts=opts.AxisOpts(type_='time') ) .set_series_opts( label_opts=opts.LabelOpts( @@ -307,7 +308,8 @@ def sport(username): ) .set_global_opts( - yaxis_opts=opts.AxisOpts(is_inverse=True) + yaxis_opts=opts.AxisOpts(is_inverse=True), + # xaxis_opts=opts.AxisOpts(type_='time') ) .set_series_opts( label_opts=opts.LabelOpts( diff --git a/app/Ui/contact/contact.py b/app/Ui/contact/contact.py index 0e05614..9743b31 100644 --- a/app/Ui/contact/contact.py +++ b/app/Ui/contact/contact.py @@ -8,13 +8,19 @@ @comment : ··· """ import datetime -from PyQt5.QtWidgets import * + from PyQt5.QtCore import * from PyQt5.QtGui import * -from .contactUi import * -from ...DataBase import data, output -from .userinfo import userinfoUi +from PyQt5.QtWidgets import * + from .analysis import analysis +from .contactUi import * +from .emotion import emotion +from .userinfo import userinfoUi +from ...DataBase import data, output + +EMOTION = 1 +ANALYSIS = 2 class ContactController(QWidget, Ui_Dialog): @@ -25,6 +31,8 @@ class ContactController(QWidget, Ui_Dialog): def __init__(self, Me, parent=None): super(ContactController, self).__init__(parent) + self.emotionView = None + self.analysisView = None self.chatroomFlag = None self.ta_avatar = None self.setupUi(self) @@ -42,18 +50,32 @@ class ContactController(QWidget, Ui_Dialog): self.last_msg_time = 0 # 上次信息的时间 self.last_talkerId = None self.now_talkerId = None + self.last_analysis = None + self.now_analysis = None + self.view_emotion = {} + self.view_analysis = {} self.showContact() - self.userinfo = userinfoUi.Ui_Frame() # 联系人信息界面 - self.userinfo.setupUi(self.frame) - self.userinfo.btn_outbut.clicked.connect(self.output) - self.userinfo.progressBar.setVisible(False) - self.userinfo.btn_analysis.clicked.connect(self.analysis) + + self.now_btn = self.userinfo + self.last_btn = None def initui(self): + self.btn_back.clicked.connect(self.back) + self.btn_output.clicked.connect(self.output) + self.btn_analysis.clicked.connect(self.analysis) + self.btn_emotion.clicked.connect(self.emotionale_Analysis) self.qurl = QUrl('baidu.com') - # self.urlSignal.connect(self.hyperlink) - # self.message.setOpenLinks(False) - # self.message.setOpenExternalLinks(False) + self.lay0 = QHBoxLayout() + self.widget.setLayout(self.lay0) + + self.frame = QtWidgets.QFrame() + self.frame.setObjectName("frame") + self.userinfo = userinfoUi.Ui_Frame() # 联系人信息界面 + self.userinfo.setupUi(self.frame) + # self.userinfo.btn_outbut.clicked.connect(self.output) + self.userinfo.progressBar.setVisible(False) + self.lay0.addWidget(self.frame) + # self.userinfo.btn_analysis.clicked.connect(self.analysis) def showContact(self): """ @@ -86,6 +108,8 @@ class ContactController(QWidget, Ui_Dialog): :return: """ self.now_talkerId = talkerId + self.frame.setVisible(True) + self.setViewVisible(self.now_talkerId) # 把当前按钮设置为灰色 if self.last_talkerId and self.last_talkerId != talkerId: print('对方账号:', self.last_talkerId) @@ -149,10 +173,70 @@ class ContactController(QWidget, Ui_Dialog): 聊天分析 :return: """ - self.analysisView = analysis.AnalysisController(self.now_talkerId) - self.analysisView.show() + self.frame.setVisible(False) + + if self.now_talkerId in self.view_analysis: + self.setViewVisible(self.now_talkerId, mod=ANALYSIS) + return True + else: + self.setViewVisible(self.now_talkerId) + self.view_analysis[self.now_talkerId] = analysis.AnalysisController(self.now_talkerId) + self.lay0.addWidget(self.view_analysis[self.now_talkerId]) + self.last_analysis = self.now_talkerId + + def emotionale_Analysis(self): + print('情感分析', data.get_conRemark(self.now_talkerId)) + self.frame.setVisible(False) + if self.now_talkerId in self.view_emotion: + self.setViewVisible(self.now_talkerId, mod=EMOTION) + return True + else: + self.setViewVisible(self.now_talkerId) + self.view_emotion[self.now_talkerId] = emotion.EmotionController(self.ta_username) + self.lay0.addWidget(self.view_emotion[self.now_talkerId]) + self.last_analysis = self.now_talkerId pass + def showUserinfo(self): + self.analysisView = analysis.AnalysisController(self.now_talkerId) + self.lay0 = QHBoxLayout() + self.widget.setLayout(self.lay0) + self.lay0.addWidget(self.analysisView) + + def back(self): + self.frame.setVisible(True) + self.setViewVisible(self.now_talkerId) + + def setViewVisible(self, wxid: str, mod=None): + """将wxid的视图设置为可见""" + if not self.last_analysis: + return False + if mod == EMOTION: + for key, value in self.view_emotion.items(): + # 如果key==wxid则将该视图设置为可见,否则不可见 + if key == wxid: + print(data.get_conRemark(wxid), '视图可见') + value.setVisible(True) + else: + print(data.get_conRemark(key), '视图不可见') + value.setVisible(False) + for key, value in self.view_analysis.items(): + value.setVisible(False) + elif mod == ANALYSIS: + for key, value in self.view_analysis.items(): + # 如果key==wxid则将该视图设置为可见,否则不可见 + if key == wxid: + value.setVisible(True) + else: + value.setVisible(False) + for key, value in self.view_emotion.items(): + value.setVisible(False) + else: + for key, value in self.view_analysis.items(): + value.setVisible(False) + for key, value in self.view_emotion.items(): + value.setVisible(False) + class Contact(QtWidgets.QPushButton): """ @@ -235,6 +319,7 @@ class Contact(QtWidgets.QPushButton): self.show_info(id) def show_info(self, id): + avatar = data.get_avator(self.username) # print(avatar) remark = data.get_conRemark(self.username) diff --git a/app/Ui/contact/contactUi.py b/app/Ui/contact/contactUi.py index 859d002..4596fba 100644 --- a/app/Ui/contact/contactUi.py +++ b/app/Ui/contact/contactUi.py @@ -14,18 +14,25 @@ from PyQt5 import QtCore, QtGui, QtWidgets class Ui_Dialog(object): def setupUi(self, Dialog): Dialog.setObjectName("Dialog") - Dialog.resize(1120, 720) + Dialog.resize(1141, 740) Dialog.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor)) Dialog.setAutoFillBackground(False) + self.horizontalLayout = QtWidgets.QHBoxLayout(Dialog) + self.horizontalLayout.setContentsMargins(0, 0, 0, 0) + self.horizontalLayout.setSpacing(0) + self.horizontalLayout.setObjectName("horizontalLayout") self.frame_2 = QtWidgets.QFrame(Dialog) - self.frame_2.setGeometry(QtCore.QRect(0, 0, 1120, 720)) self.frame_2.setFrameShape(QtWidgets.QFrame.StyledPanel) self.frame_2.setFrameShadow(QtWidgets.QFrame.Raised) self.frame_2.setObjectName("frame_2") + self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.frame_2) + self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0) + self.horizontalLayout_2.setSpacing(0) + self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.scrollArea = QtWidgets.QScrollArea(self.frame_2) self.scrollArea.setEnabled(True) - self.scrollArea.setGeometry(QtCore.QRect(0, 40, 326, 680)) - self.scrollArea.setMaximumSize(QtCore.QSize(400, 150000)) + self.scrollArea.setMinimumSize(QtCore.QSize(325, 0)) + self.scrollArea.setMaximumSize(QtCore.QSize(325, 150000)) self.scrollArea.setAutoFillBackground(False) self.scrollArea.setFrameShape(QtWidgets.QFrame.WinPanel) self.scrollArea.setFrameShadow(QtWidgets.QFrame.Raised) @@ -49,34 +56,43 @@ class Ui_Dialog(object): self.label.setGeometry(QtCore.QRect(220, 10, 72, 15)) self.label.setObjectName("label") self.scrollArea.setWidget(self.scrollAreaWidgetContents) + self.horizontalLayout_2.addWidget(self.scrollArea) self.frame = QtWidgets.QFrame(self.frame_2) - self.frame.setGeometry(QtCore.QRect(321, 0, 801, 720)) self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.frame.setFrameShadow(QtWidgets.QFrame.Raised) self.frame.setObjectName("frame") - self.line_3 = QtWidgets.QFrame(self.frame) - self.line_3.setGeometry(QtCore.QRect(2, 0, 3, 720)) - self.line_3.setLineWidth(6) - self.line_3.setFrameShape(QtWidgets.QFrame.VLine) - self.line_3.setFrameShadow(QtWidgets.QFrame.Sunken) - self.line_3.setObjectName("line_3") - self.line_2 = QtWidgets.QFrame(self.frame) - self.line_2.setGeometry(QtCore.QRect(9, 30, 831, 20)) - self.line_2.setFrameShape(QtWidgets.QFrame.HLine) - self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken) - self.line_2.setObjectName("line_2") + self.verticalLayout = QtWidgets.QVBoxLayout(self.frame) + self.verticalLayout.setObjectName("verticalLayout") + self.horizontalLayout_3 = QtWidgets.QHBoxLayout() + self.horizontalLayout_3.setObjectName("horizontalLayout_3") self.label_remark = QtWidgets.QLabel(self.frame) - self.label_remark.setGeometry(QtCore.QRect(30, 0, 351, 41)) + self.label_remark.setMaximumSize(QtCore.QSize(16777215, 100)) font = QtGui.QFont() font.setPointSize(12) self.label_remark.setFont(font) self.label_remark.setText("") self.label_remark.setObjectName("label_remark") - self.line = QtWidgets.QFrame(self.frame) - self.line.setGeometry(QtCore.QRect(20, 580, 800, 3)) - self.line.setFrameShape(QtWidgets.QFrame.HLine) - self.line.setFrameShadow(QtWidgets.QFrame.Sunken) - self.line.setObjectName("line") + self.horizontalLayout_3.addWidget(self.label_remark) + self.btn_analysis = QtWidgets.QPushButton(self.frame) + self.btn_analysis.setObjectName("btn_analysis") + self.horizontalLayout_3.addWidget(self.btn_analysis) + self.btn_emotion = QtWidgets.QPushButton(self.frame) + self.btn_emotion.setObjectName("btn_emotion") + self.horizontalLayout_3.addWidget(self.btn_emotion) + self.btn_output = QtWidgets.QPushButton(self.frame) + self.btn_output.setObjectName("btn_output") + self.horizontalLayout_3.addWidget(self.btn_output) + self.btn_back = QtWidgets.QPushButton(self.frame) + self.btn_back.setObjectName("btn_back") + self.horizontalLayout_3.addWidget(self.btn_back) + self.verticalLayout.addLayout(self.horizontalLayout_3) + self.widget = QtWidgets.QWidget(self.frame) + self.widget.setObjectName("widget") + self.verticalLayout.addWidget(self.widget) + self.verticalLayout.setStretch(0, 1) + self.verticalLayout.setStretch(1, 30) + self.horizontalLayout_2.addWidget(self.frame) + self.horizontalLayout.addWidget(self.frame_2) self.retranslateUi(Dialog) QtCore.QMetaObject.connectSlotsByName(Dialog) @@ -85,3 +101,7 @@ class Ui_Dialog(object): _translate = QtCore.QCoreApplication.translate Dialog.setWindowTitle(_translate("Dialog", "Dialog")) self.label.setText(_translate("Dialog", "TextLabel")) + self.btn_analysis.setText(_translate("Dialog", "统计信息")) + self.btn_emotion.setText(_translate("Dialog", "情感分析")) + self.btn_output.setText(_translate("Dialog", "导出聊天记录")) + self.btn_back.setText(_translate("Dialog", "退出")) diff --git a/app/Ui/contact/contactUi.ui b/app/Ui/contact/contactUi.ui index 077a18a..79d27eb 100644 --- a/app/Ui/contact/contactUi.ui +++ b/app/Ui/contact/contactUi.ui @@ -1,208 +1,225 @@ - Dialog - - - - 0 - 0 - 1120 - 720 - - - - ArrowCursor - - - Dialog - - - false - - - - - 0 - 0 - 1120 - 720 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - true - - - - 0 - 40 - 326 - 680 - - - - - 400 - 150000 - - - - false - - - QFrame::WinPanel - - - QFrame::Raised - - - 0 - - - Qt::ScrollBarAlwaysOn - - - Qt::ScrollBarAlwaysOff - - - QAbstractScrollArea::AdjustToContentsOnFirstShow - - - false - - - - - 0 - 0 - 300 - 12000 - - - - - - 0 - 0 - 300 - 80 - - - - Qt::LeftToRight - - - false - - - - - - - 80 - 80 - - - - - - - 220 - 10 - 72 - 15 - - - - TextLabel - - + Dialog + + + + 0 + 0 + 1141 + 740 + + + + ArrowCursor + + + Dialog + + + false + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + true + + + + 325 + 0 + + + + + 325 + 150000 + + + + false + + + QFrame::WinPanel + + + QFrame::Raised + + + 0 + + + Qt::ScrollBarAlwaysOn + + + Qt::ScrollBarAlwaysOff + + + QAbstractScrollArea::AdjustToContentsOnFirstShow + + + false + + + + + 0 + 0 + 300 + 12000 + + + + + + 0 + 0 + 300 + 80 + + + + Qt::LeftToRight + + + false + + + + + + + 80 + 80 + + + + + + + 220 + 10 + 72 + 15 + + + + TextLabel + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + 16777215 + 100 + + + + + 12 + + + + + + + + + + + 统计信息 + + + + + + + 情感分析 + + + + + + + 导出聊天记录 + + + + + + + 退出 + + + + + + + + + + + + + + + - - - - - 321 - 0 - 801 - 720 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - 2 - 0 - 3 - 720 - - - - 6 - - - Qt::Vertical - - - - - - 9 - 30 - 831 - 20 - - - - Qt::Horizontal - - - - - - 30 - 0 - 351 - 41 - - - - - 12 - - - - - - - - - - 20 - 580 - 800 - 3 - - - - Qt::Horizontal - - - - - - - + + diff --git a/app/Ui/contact/emotion/__init__.py b/app/Ui/contact/emotion/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/Ui/contact/emotion/emotionUi.ui b/app/Ui/contact/emotion/emotionUi.ui new file mode 100644 index 0000000..4d9e1ab --- /dev/null +++ b/app/Ui/contact/emotion/emotionUi.ui @@ -0,0 +1,19 @@ + + Dialog + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + + + diff --git a/app/Ui/mainview.py b/app/Ui/mainview.py index 951d761..8b3240d 100644 --- a/app/Ui/mainview.py +++ b/app/Ui/mainview.py @@ -13,12 +13,12 @@ from PyQt5.QtGui import * from PyQt5.QtWidgets import * from app.DataBase import data +from . import mainwindow from .chat import chat from .contact import contact -from .mainviewUi import * -class MainWinController(QMainWindow, Ui_Dialog): +class MainWinController(QMainWindow, mainwindow.Ui_MainWindow): exitSignal = pyqtSignal() # username = '' @@ -28,10 +28,22 @@ class MainWinController(QMainWindow, Ui_Dialog): self.setWindowTitle('WeChat') self.setWindowIcon(QIcon('./app/data/icon.png')) self.Me = data.get_myinfo() - self.chatView = chat.ChatController(self.Me, parent=self.frame_main) + self.setAttribute(Qt.WA_AttributeCount) + + self.chatView = chat.ChatController(self.Me, parent=None) self.chatView.setVisible(False) - self.contactView = contact.ContactController(self.Me, parent=self.frame_main) + # self.chatView.setLayout() + self.lay = QHBoxLayout() + self.frame_main.setLayout(self.lay) + self.lay.addWidget(self.chatView) + # self.frame_main.setLayout(self.chatView) + # self.frame_main.setLayout() + self.contactView = contact.ContactController(self.Me, parent=None) self.contactView.setVisible(False) + self.lay0 = QHBoxLayout() + self.frame_main.setLayout(self.lay0) + self.lay.addWidget(self.contactView) + # self.myinfoView = userinfo.MyinfoController(self.Me, parent=self.frame_main) # self.myinfoView.setVisible(False) self.btn_chat.clicked.connect(self.chat_view) # 聊天按钮 diff --git a/app/Ui/mainviewUi.py b/app/Ui/mainviewUi.py index 17a84be..1486d35 100644 --- a/app/Ui/mainviewUi.py +++ b/app/Ui/mainviewUi.py @@ -14,61 +14,70 @@ from PyQt5 import QtCore, QtGui, QtWidgets class Ui_Dialog(object): def setupUi(self, Dialog): Dialog.setObjectName("Dialog") - Dialog.resize(1280, 720) + Dialog.resize(1244, 738) Dialog.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor)) Dialog.setAutoFillBackground(False) self.frame_main = QtWidgets.QFrame(Dialog) - self.frame_main.setGeometry(QtCore.QRect(160, 0, 1120, 720)) + self.frame_main.setGeometry(QtCore.QRect(115, 9, 1120, 720)) + self.frame_main.setMinimumSize(QtCore.QSize(1120, 720)) + self.frame_main.setLayoutDirection(QtCore.Qt.LeftToRight) self.frame_main.setFrameShape(QtWidgets.QFrame.StyledPanel) self.frame_main.setFrameShadow(QtWidgets.QFrame.Raised) self.frame_main.setObjectName("frame_main") self.frame_info = QtWidgets.QFrame(Dialog) - self.frame_info.setGeometry(QtCore.QRect(0, 0, 161, 721)) + self.frame_info.setGeometry(QtCore.QRect(9, 9, 100, 720)) + self.frame_info.setMinimumSize(QtCore.QSize(100, 500)) self.frame_info.setStyleSheet("background-color:rgb(240,240,240)") self.frame_info.setFrameShape(QtWidgets.QFrame.StyledPanel) self.frame_info.setFrameShadow(QtWidgets.QFrame.Sunken) self.frame_info.setObjectName("frame_info") self.verticalLayoutWidget = QtWidgets.QWidget(self.frame_info) - self.verticalLayoutWidget.setGeometry(QtCore.QRect(20, 190, 111, 501)) + self.verticalLayoutWidget.setGeometry(QtCore.QRect(0, 190, 91, 271)) self.verticalLayoutWidget.setObjectName("verticalLayoutWidget") self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.verticalLayoutWidget) self.verticalLayout_2.setContentsMargins(0, 0, 0, 0) self.verticalLayout_2.setSpacing(0) self.verticalLayout_2.setObjectName("verticalLayout_2") self.btn_chat = QtWidgets.QPushButton(self.verticalLayoutWidget) - self.btn_chat.setMinimumSize(QtCore.QSize(0, 80)) + self.btn_chat.setMinimumSize(QtCore.QSize(0, 60)) self.btn_chat.setStyleSheet("QPushButton {background-color: rgb(240,240,240);}\n" -"QPushButton:hover{background-color: rgb(209,209,209);}") + " QPushButton:hover{background-color: rgb(209,209,209);}\n" + " ") self.btn_chat.setObjectName("btn_chat") self.verticalLayout_2.addWidget(self.btn_chat) self.btn_contact = QtWidgets.QPushButton(self.verticalLayoutWidget) - self.btn_contact.setMinimumSize(QtCore.QSize(0, 80)) + self.btn_contact.setMinimumSize(QtCore.QSize(0, 60)) self.btn_contact.setStyleSheet("QPushButton {background-color: rgb(240,240,240);}\n" -"QPushButton:hover{background-color: rgb(209,209,209);}") + " QPushButton:hover{background-color: rgb(209,209,209);}\n" + " ") self.btn_contact.setObjectName("btn_contact") self.verticalLayout_2.addWidget(self.btn_contact) self.btn_myinfo = QtWidgets.QPushButton(self.verticalLayoutWidget) - self.btn_myinfo.setMinimumSize(QtCore.QSize(100, 80)) + self.btn_myinfo.setMinimumSize(QtCore.QSize(60, 60)) self.btn_myinfo.setStyleSheet("QPushButton {background-color: rgb(240,240,240);}\n" -"QPushButton:hover{background-color: rgb(209,209,209);}") + " QPushButton:hover{background-color: rgb(209,209,209);}\n" + " ") self.btn_myinfo.setObjectName("btn_myinfo") self.verticalLayout_2.addWidget(self.btn_myinfo) self.btn_about = QtWidgets.QPushButton(self.verticalLayoutWidget) - self.btn_about.setMinimumSize(QtCore.QSize(100, 80)) + self.btn_about.setMinimumSize(QtCore.QSize(60, 60)) self.btn_about.setStyleSheet("QPushButton {background-color: rgb(240,240,240);}\n" -"QPushButton:hover{background-color: rgb(209,209,209);}") + " QPushButton:hover{background-color: rgb(209,209,209);}\n" + " ") self.btn_about.setObjectName("btn_about") self.verticalLayout_2.addWidget(self.btn_about) self.verticalLayout_2.setStretch(0, 1) + self.verticalLayout_2.setStretch(1, 1) self.verticalLayout_2.setStretch(2, 1) + self.verticalLayout_2.setStretch(3, 1) self.myavatar = QtWidgets.QLabel(self.frame_info) - self.myavatar.setGeometry(QtCore.QRect(30, 50, 100, 100)) + self.myavatar.setGeometry(QtCore.QRect(10, 40, 80, 80)) self.myavatar.setObjectName("myavatar") self.sign_up = QtWidgets.QPushButton(self.frame_info) - self.sign_up.setGeometry(QtCore.QRect(0, 0, 71, 28)) + self.sign_up.setGeometry(QtCore.QRect(0, 0, 40, 28)) self.sign_up.setObjectName("sign_up") self.btn_destroy = QtWidgets.QPushButton(self.frame_info) - self.btn_destroy.setGeometry(QtCore.QRect(80, 0, 71, 28)) + self.btn_destroy.setGeometry(QtCore.QRect(50, 0, 40, 28)) self.btn_destroy.setObjectName("btn_destroy") self.retranslateUi(Dialog) @@ -82,5 +91,5 @@ class Ui_Dialog(object): self.btn_myinfo.setText(_translate("Dialog", "我的")) self.btn_about.setText(_translate("Dialog", "关于")) self.myavatar.setText(_translate("Dialog", "avatar")) - self.sign_up.setText(_translate("Dialog", "退出登录")) - self.btn_destroy.setText(_translate("Dialog", "注销账户")) + self.sign_up.setText(_translate("Dialog", "退出")) + self.btn_destroy.setText(_translate("Dialog", "注销")) diff --git a/app/Ui/mainviewUi.ui b/app/Ui/mainviewUi.ui index 64f4302..4f39e12 100644 --- a/app/Ui/mainviewUi.ui +++ b/app/Ui/mainviewUi.ui @@ -6,8 +6,8 @@ 0 0 - 1280 - 720 + 1244 + 738 @@ -22,12 +22,21 @@ - 160 - 0 + 115 + 9 1120 720 + + + 1120 + 720 + + + + Qt::LeftToRight + QFrame::StyledPanel @@ -38,12 +47,18 @@ - 0 - 0 - 161 - 721 + 9 + 9 + 100 + 720 + + + 100 + 500 + + background-color:rgb(240,240,240) @@ -56,13 +71,13 @@ - 20 + 0 190 - 111 - 501 + 91 + 271 - + 0 @@ -71,7 +86,7 @@ 0 - 80 + 60 @@ -89,7 +104,7 @@ 0 - 80 + 60 @@ -106,8 +121,8 @@ - 100 - 80 + 60 + 60 @@ -124,8 +139,8 @@ - 100 - 80 + 60 + 60 @@ -143,10 +158,10 @@ - 30 - 50 - 100 - 100 + 10 + 40 + 80 + 80 @@ -158,25 +173,25 @@ 0 0 - 71 + 40 28 - 退出登录 + 退出 - 80 + 50 0 - 71 + 40 28 - 注销账户 + 注销 diff --git a/app/Ui/mainwindow.ui b/app/Ui/mainwindow.ui new file mode 100644 index 0000000..304fb22 --- /dev/null +++ b/app/Ui/mainwindow.ui @@ -0,0 +1,251 @@ + + + MainWindow + + + + 0 + 0 + 1280 + 779 + + + + MainWindow + + + + + 0 + + + 0 + + + 0 + + + + + + 100 + 500 + + + + + 100 + 16777215 + + + + background-color:rgb(240,240,240) + + + QFrame::StyledPanel + + + QFrame::Sunken + + + + + 0 + 190 + 91 + 271 + + + + + 0 + + + + + + 0 + 60 + + + + QPushButton {background-color: rgb(240,240,240);} + QPushButton:hover{background-color: rgb(209,209,209);} + + + + 聊天 + + + + + + + + 0 + 60 + + + + QPushButton {background-color: rgb(240,240,240);} + QPushButton:hover{background-color: rgb(209,209,209);} + + + + 联系人 + + + + + + + + 60 + 60 + + + + QPushButton {background-color: rgb(240,240,240);} + QPushButton:hover{background-color: rgb(209,209,209);} + + + + 我的 + + + + + + + + 60 + 60 + + + + QPushButton {background-color: rgb(240,240,240);} + QPushButton:hover{background-color: rgb(209,209,209);} + + + + 关于 + + + + + + + + + 10 + 40 + 80 + 80 + + + + avatar + + + + + + 0 + 0 + 40 + 28 + + + + 退出 + + + + + + 50 + 0 + 40 + 28 + + + + 注销 + + + + + + + + + 1120 + 720 + + + + Qt::LeftToRight + + + QFrame::Box + + + QFrame::Raised + + + + + + + + + 0 + 0 + 1280 + 23 + + + + + 文件(F) + + + + + + + + + 编辑 + + + + + 帮助 + + + + + + + + + + + 保存 + + + + + 退出 + + + + + 关于 + + + + + + diff --git a/main.py b/main.py index 5614723..e71209b 100644 --- a/main.py +++ b/main.py @@ -7,12 +7,16 @@ from app.Ui import * # class ViewController: + def __init__(self): + self.viewMainWIn = None + self.viewDecrypt = None + def loadDecryptView(self): """ 登录界面 :return: """ - self.viewDecrypt = decrypt.DecryptControl() # 需要将viewlogin设为成员变量 + self.viewDecrypt = decrypt.DecryptControl() # 需要将view login设为成员变量 self.viewDecrypt.DecryptSignal.connect(self.loadMainWinView) self.viewDecrypt.registerSignal.connect(self.loadRegisterView) self.viewDecrypt.show() @@ -24,7 +28,7 @@ class ViewController: :return: """ pass - # self.viewDecrypt = register.registerControl() # 需要将viewlogin设为成员变量 + # self.viewDecrypt = register.registerControl() # 需要将view login设为成员变量 # self.viewDecrypt.DecryptSignal.connect(self.loadDecryptView) # self.viewDecrypt.show() @@ -47,6 +51,6 @@ class ViewController: if __name__ == '__main__': app = QApplication(sys.argv) view = ViewController() - view.loadDecryptView() # 进入登录界面,如果viewlogin不是成员变量,则离开作用域后失效。 - # view.loadMainWinView('102') + # view.loadDecryptView() # 进入登录界面,如果view login不是成员变量,则离开作用域后失效。 + view.loadMainWinView('102') sys.exit(app.exec_()) diff --git a/test.html b/test.html deleted file mode 100644 index 9ed6e65..0000000 --- a/test.html +++ /dev/null @@ -1,149 +0,0 @@ - - - - - Title - - - - -
- - - - - - - - - > - - - - - - - -
- - - - - - - - - ADC
- %s 13245: -
-
- - - - - - Document - - - - - - - - - - - - - - - - - - - - - - - - - - - -
我是标题
英雄性别职业
亚索中单
卡莎ADC
寒冰
- - - - - \ No newline at end of file diff --git a/wechat.html b/wechat.html deleted file mode 100644 index 15d1ce8..0000000 --- a/wechat.html +++ /dev/null @@ -1,55 +0,0 @@ - - - - 聊天时间 - - - - -
- 你好 -
- - - - \ No newline at end of file