-
大小: 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遗传算法 源代码
相关资源
- python+ selenium教程
- PycURL(Windows7/Win32)Python2.7安装包 P
- 英文原版-Scientific Computing with Python
- 基于python-flask的个人博客系统
- python 调用sftp断点续传文件
- python socket游戏
- IIs put上传工具
- python实现自动操作windows应用
- csv文件行列转换python实现代码
- Python操作Mysql教程手册
- DeepLabV3-Tensorflow-master
- Python Machine Learning Case Studies
- 量化交易(附python常见函数的使用方
- Python串口通信(pyserial)
- django图片浏览+scrapy实现数据抓取功能
- jetbrains-agent.jar(pycharm破解包)
- 豆瓣爬虫;Scrapy框架
-
Python sc
ript for fix VxWorks SymTbl in IDA - Django+MySql增删改查入门案例(附数据
- Django博客+pyecharts动态折线图+mysql
- python 语音提示( 基于SAPI.SPVOICE)
- Spacetime Texture Representation and Recogniti
- scrapy框架爬取58同城数据
- scrapy 爬取图片clj
- RSA数字签名59991
- cs破解工具
- Python Libraries(python编程常用库教程)
- NSGA3多目标优化算法
- 深度学习(SPOT-RNA)
- 多项式拟合(LSM.py)
评论
共有 条评论