Featured program examples
Python+Qt desktop and webpage manual customer service communication tool
If you need to install the operating environment or remote debugging, see the personal QQ business card at the bottom of the article, and professional and technical personnel will assist remotely!
foreword
This blog writes codes for <<Python+Qt desktop and webpage manual customer service communication tools>>, the code is neat, regular and easy to read. The first choice for learning and application recommendation.
Function: If there is a user inquiry message on the webpage, the desktop program will receive the user inquiry information sent by the webpage in time, so that the customer service can check and reply in time.
Article directory
1. Required tool software
2. Use steps
1. Import library
2. Code implementation
3. Running results
3. Online assistance
1. Required tool software
1. Python, Qt
2. Database
2. Use steps
1. Import library
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. Code implementation
code show as below:
# 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. Running results
3. Online assistance:
If you need to install the operating environment or remote debugging, see the personal QQ business card at the bottom of the article, and professional and technical personnel will assist remotely!
1) Remote installation and operation environment, code debugging
2) Qt, C++, Python entry guide
3) Interface beautification
4) Software production
Current article link: https://blog.csdn.net/alicema1111/article/details/131258803
Blogger recommended article: python face recognition statistics qt form - CSDN Blog
Blogger recommended article: Python Yolov5 flame smoke recognition source code sharing - CSDN blog
Personal blog homepage: alicema1111's blog_CSDN blog-Python, C++, bloggers in the field of web pages
Click here for all the blogger's articles : alicema1111's blog_CSDN blog-Python, C++, bloggers in the field of web pages