优化加载页面

This commit is contained in:
shuaikangzhou 2023-03-06 00:39:40 +08:00
parent efe314d5e6
commit aeefce19b5
5 changed files with 35 additions and 29 deletions

50
TEST.py
View File

@ -1,29 +1,25 @@
from PyQt5 import QtCore, QtGui, QtWidgets
import time
import os
import openai
class MyWindow(QtWidgets.QPushButton):
print("欢迎使用ChatGPT智能问答请在Q:后面输入你的问题输入quit退出")
openai.api_key = '''eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6Ik1UaEVOVUpHTkVNMVFURTRNMEZCTWpkQ05UZzVNRFUxUlRVd1FVSkRNRU13UmtGRVFrRXpSZyJ9.eyJodHRwczovL2FwaS5vcGVuYWkuY29tL3Byb2ZpbGUiOnsiZW1haWwiOiI4NjM5MDk2OTRAcXEuY29tIiwiZW1haWxfdmVyaWZpZWQiOnRydWUsImdlb2lwX2NvdW50cnkiOiJVUyJ9LCJodHRwczovL2FwaS5vcGVuYWkuY29tL2F1dGgiOnsidXNlcl9pZCI6InVzZXItdmdiMG1IeU5MQUNHRG1qRndrekVMNVM3In0sImlzcyI6Imh0dHBzOi8vYXV0aDAub3BlbmFpLmNvbS8iLCJzdWIiOiJhdXRoMHw2M2RjYmNiZWRiNzFkNmVhMzA5YmEzYzciLCJhdWQiOlsiaHR0cHM6Ly9hcGkub3BlbmFpLmNvbS92MSIsImh0dHBzOi8vb3BlbmFpLm9wZW5haS5hdXRoMGFwcC5jb20vdXNlcmluZm8iXSwiaWF0IjoxNjc1NDEyNTg2LCJleHAiOjE2NzYwMTczODYsImF6cCI6IlRkSkljYmUxNldvVEh0Tjk1bnl5d2g1RTR5T282SXRHIiwic2NvcGUiOiJvcGVuaWQgcHJvZmlsZSBlbWFpbCBtb2RlbC5yZWFkIG1vZGVsLnJlcXVlc3Qgb3JnYW5pemF0aW9uLnJlYWQgb2ZmbGluZV9hY2Nlc3MifQ.dlTy6oc0eIDIJg0AqlFdarXWh7h-n7C6id3Kv5-uOrASoYB3qtfhPMuj15yV0VOOmFyj_L7v3MCpPEnsJp08NJo1Jn32jKtCkKD-sy8DpT5rafj_B6TKNvEBsqdXgDENg0ly9KiAjS-HDlCmQoBEqg-kc2VaqlpPIfk-164WI2SCTgQb50GNKWu0jwG-lx8BHnY8gUqC7sGVx4Hg9sLHccyAL93kMu4NS-S9CsqNefYAolLbqQLPBOG9MFaTD1jvyZpuqwm3eiv7HwgHempVWAfCK9sfGBblExHRT5zi0oSGwwBGmi2EnBHjEX185RRqtuH_uKRwp47m0TcHulJsfQ'''
def __init__(self):
QtWidgets.QPushButton.__init__(self)
self.setText("关闭窗口")
self.clicked.connect(QtWidgets.qApp.quit)
def load_data(self, sp):
for i in range(1, 11): #模拟主程序加载过程
time.sleep(2) # 加载数据
sp.showMessage("加载... {0}%".format(i * 10), QtCore.Qt.AlignHCenter |QtCore.Qt.AlignBottom, QtCore.Qt.black)
QtWidgets.qApp.processEvents() # 允许主进程处理事件
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
splash = QtWidgets.QSplashScreen(QtGui.QPixmap("img.jpg"))
splash.showMessage("加载... 0%", QtCore.Qt.AlignHCenter | QtCore.Qt.AlignBottom, QtCore.Qt.black)
splash.show() # 显示启动界面
QtWidgets.qApp.processEvents() # 处理主进程事件
window = MyWindow()
window.setWindowTitle("QSplashScreen类使用")
window.resize(300, 30)
window.load_data(splash) # 加载数据
window.show()
splash.finish(window) # 隐藏启动界面
start_sequence = "\nA:"
restart_sequence = "\nQ: "
while True:
prompt = input(restart_sequence)
if prompt == 'quit':
break
else:
try:
response = openai.Completion.create(
model="text-davinci-003", # 这里我们使用的是davinci-003的模型准确度更高。
prompt=prompt,
temperature=1,
max_tokens=2000, # 这里限制的是回答的长度,你可以可以限制字数,如:写一个300字作文等。
frequency_penalty=0,
presence_penalty=0
)
print(start_sequence, response["choices"][0]["text"].strip())
except Exception as exc: # 捕获异常后打印出来
print(exc)

View File

@ -370,7 +370,6 @@ class ChildThread(QThread):
doc.save(filename)
def run(self):
self.to_docx(self.message, self.num, self.conRemark)

View File

@ -102,7 +102,7 @@ def message_word_cloud(username):
text_data = sorted(wordcount.items(), key=lambda x: x[1], reverse=True)
if len(text_data) > 100:
text_data = text_data[:100]
print(text_data)
# print(text_data)
(
WordCloud(init_opts=opts.InitOpts(width="900px", height="550px"))
.add(series_name="聊天文字", data_pair=text_data, word_size_range=[20, 100])

View File

@ -46,6 +46,7 @@ class ContactController(QWidget, Ui_Dialog):
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)
def initui(self):
@ -125,6 +126,15 @@ class ContactController(QWidget, Ui_Dialog):
self.outputThread.start()
def hide_progress_bar(self, int):
reply = QMessageBox(self)
reply.setIcon(QMessageBox.Information)
reply.setWindowTitle('OK')
reply.setText("导出聊天记录成功")
reply.addButton("确认", QMessageBox.AcceptRole)
reply.addButton("取消", QMessageBox.RejectRole)
# reply.addButton("忽略", QMessageBox.DestructiveRole)
print(reply)
api = reply.exec_()
self.userinfo.progressBar.setVisible(False)
def set_progressBar_range(self, value):

View File

@ -5,6 +5,7 @@ import sys
from app.Ui import *
#
class ViewController:
def loadDecryptView(self):
"""