程序示例精选
Python+Qt桌面端与网页端人工客服沟通工具
如需安装运行环境或远程调试,见文章底部个人QQ名片,由专业技术人员远程协助!
前言
这篇博客针对<<Python+Qt桌面端与网页端人工客服沟通工具>>编写代码,代码整洁,规则,易读。 学习与应用推荐首选。
功能:网页中如有用户询问留言,桌面端程序会及时收到网页传送的用户询问信息,以便得到客服及时查看回复。
文章目录
一、所需工具软件
二、使用步骤
1. 引入库
2. 代码实现
3. 运行结果
三、在线协助
一、所需工具软件
1. Python, Qt
2. 数据库
二、使用步骤
1.引入库
import cv2
import sys
import os
import random
from mainWindow import Ui_MainWindow
from PyQt5 import QtWidgets, QtCore, QtGui
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
2. 代码实现
代码如下:
# coding:utf-8
# import sys
#从转换的.py文件内调用类
import cv2
import sys
import os
import random
from mainWindow import Ui_MainWindow
from PyQt5 import QtWidgets, QtCore, QtGui
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
class myWin(QtWidgets.QMainWindow,Ui_MainWindow):
def __init__(self):
super(myWin, self).__init__()
self.setupUi(self)
#closeEvent2暂时不用
def closeEvent2(self, event):
self.box = QMessageBox(QMessageBox.Warning, "系统提示信息", "是否暂停摄像头?")
qyes = self.box.addButton(self.tr("是"), QMessageBox.YesRole)
qno = self.box.addButton(self.tr("否"), QMessageBox.NoRole)
self.box.exec_()
if self.box.clickedButton() == qyes:
self.label.clear()
while 1:
if cv2.waitKey(1) == ord('q'):
break
self.cap.release()
cv2.destroyAllWindows()
else:
event.ignore()
# # 退出系统窗口 X 绑定函数事件
def closeEvent(self, event):
# print("test")
self.box = QMessageBox(QMessageBox.Warning, "系统提示信息", "是否退出系统?")
qyes = self.box.addButton(self.tr("是"), QMessageBox.YesRole)
qno = self.box.addButton(self.tr("否"), QMessageBox.NoRole)
self.box.exec_()
if self.box.clickedButton() == qyes:
event.accept()
QtWidgets.QWidget.closeEvent(self, event)
sys.exit().accept()
else:
event.ignore()
def videoRecog2(self):
print("videoRecog2")
global receiveID
#receiveID = self.lineEdit.text()
receiveID = "001"
print("receiveID", receiveID)
#得到receive信息*********************************************************
# try:
import sqlite3
import datetime
from datetime import datetime
conn = sqlite3.connect("record.db", check_same_thread=False)
curr = conn.cursor()
curr.execute('select name from record where id="' + receiveID + '"')
result2 = curr.fetchall()
print("result2:", result2)
curr.execute('select receive from record where id="' + receiveID + '"')
result3 = curr.fetchall()
print("result3:", result3)
curr.execute('select record_time_receive from record where id="' + receiveID + '"')
result4 = curr.fetchall()
print("result4:", result4)
curr.execute('select receive_history from record where id="' + receiveID + '"')
result5 = curr.fetchall()
print("result5:", result5)
# if result2 and result3 and result4:
# for i in result2: i = list(i); result2 = ','.join(i)
# for i in result3: i = list(i); result3 = ','.join(i)
# for i in result4: i = list(i); result4 = ','.join(i)
print("result2", result2)
print("result3", result3)
print("result4", result4)
print("result5", result5)
if result4 != result5:
self.textEdit.append("")
self.textEdit.append(str(receiveID)+" "+"收到的信息")
self.textEdit.append("时间:" + result4)
self.textEdit.append("内容:"+result3)
# 得到receive信息_结束***********************************************
#保存receive信息到receive_history里面
curr.execute('update record set receive_history = "' + str(result4) + '" where id="' + str(receiveID) + '"')
# 保存receive信息到receive_history里面_结束
# except:
# print("lineEditor is blank")
conn.commit()
curr.close()
conn.close()
def sendoutInfor(self):
#receiveID = self.lineEdit.text()
receiveID = "001"
print("receiveID", receiveID)
print("sendoutInfor")
sendOut = self.textEdit_2.toPlainText()
print("sendOut", sendOut)
#送出信息*********************************************************
# try:
import sqlite3
import datetime
from datetime import datetime
conn = sqlite3.connect("record.db", check_same_thread=False)
curr = conn.cursor()
curr.execute('update record set sendout = "' + str(sendOut) + '" where id="' + str(receiveID) + '"')
curr.execute('update record set record_time_sendout = "' + currentTime + '" where id="' + str(receiveID) + '"')
self.textEdit.append("")
self.textEdit.append(str(receiveID)+" " + "发送的信息")
# except:
# print("lineEditor is blank")
conn.commit()
curr.close()
conn.close()
def set_line_color(text_edit, line_number, color):
cursor = text_edit.textCursor()
cursor.movePosition(cursor.Start)
for i in range(line_number - 1):
cursor.movePosition(cursor.NextBlock)
cursor.select(cursor.BlockUnderCursor)
format = QTextCharFormat()
format.setForeground(color)
cursor.mergeCharFormat(format)
if __name__=="__main__":
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
app=QtWidgets.QApplication(sys.argv)
Widget=myWin()
Widget.showMaximized();
Widget.show()
sys.exit(app.exec_())
3. 运行结果
三、在线协助:
如需安装运行环境或远程调试,见文章底部个人 QQ 名片,由专业技术人员远程协助!
1)远程安装运行环境,代码调试
2)Qt, C++, Python入门指导
3)界面美化
4)软件制作
当前文章连接:https://blog.csdn.net/alicema1111/article/details/131258803
博主推荐文章:python人脸识别统计人数qt窗体-CSDN博客
博主推荐文章:Python Yolov5火焰烟雾识别源码分享-CSDN博客
Python OpenCV识别行人入口进出人数统计_python识别人数-CSDN博客
个人博客主页:alicema1111的博客_CSDN博客-Python,C++,网页领域博主
博主所有文章点这里:alicema1111的博客_CSDN博客-Python,C++,网页领域博主