-
大小: 9KB文件类型: .py金币: 1下载: 0 次发布日期: 2021-05-14
- 语言: Python
- 标签: subprocess
资源简介
PyQt5中异步刷新UI和Python中的多线程总结
学习python和PyQt5的过程中,做了demo,可以从电脑端向手push文件和安装apk的GUIdemo,初学者可从这个例子中学到很多知识。涉及到PyQt5中异步刷新UI+Python中的多线程+python中使用subprocess。可结合我的博客学习https://blog.csdn.net/u013247461/article/details/85063455
代码片段和文件信息
# -*- coding: utf-8 -*-
# Autho:chenghao Albert Time:2018/12/17
# -*- coding: utf-8 -*-
# Autho:chenghao Albert Time:2018/12/10
import sys
import tkinter.messagebox
import tkinter as tk
import tkinter
import threading
import subprocess
from PyQt5 import QtCore QtGui QtWidgets
from PyQt5.QtWidgets import QMessageBox
from PyQT_Form import Ui_MainWindow
class MyPyQT_Form(QtWidgets.QMainWindow Ui_MainWindow):
def __init__(self parent=None):
super(MyPyQT_Form self).__init__(parent)
self.setupUi(self)
# self.retranslateUi(self)
self.pushButton.clicked.connect(self.pushButton_click)
self.pushButton_help.clicked.connect(self.softHelp)
self.pushButton_about.clicked.connect(self.softAbout)
self.thread = AnalysisLogThread()
# 开始按钮按下后使其不可用,启动线程
self.thread.sinOut.connect(self.showMsg_1)
self.thread.enablepb.connect(self.enablePushButton)
self.thread.setpb.connect(self.setProcessBarValue)
self.thread.popmsg.connect(self.popMessageBox)
def closeEvent(self event): # 关闭窗口触发以下事件
reply = QMessageBox.question(self ‘title‘ ‘Are you sure to qiut?‘ QMessageBox.Yes | QMessageBox.No QMessageBox.No)
if reply == QMessageBox.Yes:
event.accept() #接受关闭事件
else:
event.ignore() #忽略关闭事件
def softHelp(self):
QMessageBox.information(self “HELP“ ‘ This tool is used to import resources and install apk for testing.‘)
def softAbout(self):
QMessageBox.information(self‘ABOUT‘ ‘For internal use only by Sagereal please do not spread without authorization!‘
‘\n ‘
‘\n Author : chenghao‘
‘\n Mail : chenghao@sagereal.com ‘
‘\n Org : Sagereal ‘
‘\n Team : Automation ‘
‘\n Version : V001 ‘
‘\n Date : 2018-12-17‘)
def showMsg_1(self str):
print(“call showMsg_1()“)
print(str)
self.listWidget.addItem(str)
def enablePushButton(self):
self.pushButton.setEnabled(True)
# 实现pushButton_click()函数,textEdit是我们放上去的文本框的id
def pushButton_click(self):
self.listWidget.clear()
self.progressBar.setProperty(“value“ 0)
self.pushButton.setEnabled(False)
self.thread.start()
def setProcessBarValue(selfnum):
self.progressBar.setProperty(“value“ num)
def popMessageBox(self str):
reply = QMessageBox.information(self ‘Prompt‘ str)
class AnalysisLogThread(QtCore.QThread):
sinOut = QtCore.pyqtSignal(str)
enablepb = QtCore.pyqtSignal()
setpb= QtCore.pyqtSignal(int)
popmsg= QtCore.pyqtSignal(str)
- 上一篇:一加云服务照片批量导出 Python爬虫
- 下一篇:python遗传算法 源代码
相关资源
- 基于TensorFlow实现的闲聊机器人
- datingTestSet2.txt
- 1.2.5的windows python-mysqlpip安装,MySQL_
- _sqlite3.cpython-38-x86_64-linux-gnu.rar
- SCU微服务自动填写
- 基于socket的python聊天
- python之des加密算法
- samylee的ssd_pascal文件
- vgg_easy.py
- keywordsearch
- scel2txt.py
- 颜色识别+串口通信——华北五省ope
- openSMILE批量提取音频情感特征
- 粒子群优化BPNN的python实现代码.rar
- CBAM_MNIST.py
- DynaSLAM/src/python/
- 利用keras实现的cnn卷积神经网络对手写
-
python2.7sc
ript目录 - snn脉冲神经网络.py
- GrabClass.py爬取武汉理工大学课表
- KMeans python 代码
- shuake.py
- python实现类似于QQ或MSN的聊天系统
- sm4国密算法python实现
- k均值K-means算法案例,包括K=2和肘部法
- 支持向量机SVM求解鸢尾花分类问题(
- ngramScore适应度计算文件(包含引入的
- 批量插入内聚单元的py文件
- PSO优化的BP神经网络——python实现
- 漏洞验证脚本ssl-deacth-alert(cve-2016-
评论
共有 条评论