所以基本上我有一些程序,用来显示在后台逐行读取excel文件的进度。到目前为止,我有以下代码:
在卓越结果.py公司名称:
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import pyqtSlot
from PyQt5.QtCore import Qt, QBasicTimer
import os, sys, xlrd, threading, time, pythoncom
import win32com.client
from time import sleep
from test import MyGlobals
class ExcelCheck(threading.Thread):
progPercent = 0
def __init__(self):
threading.Thread.__init__(self)
self.event = threading.Event()
def run(self):
pythoncom.CoInitialize()
try:
while not self.event.is_set():
excel = win32com.client.Dispatch("Excel.Application")
wb = excel.ActiveWorkbook
ws = wb.Worksheets("TC")
va_title = ws.Range(ws.Range('I7'), ws.Range('I700'))
i = 0
for r in va_title.Cells:
if r.Text != '':
i = i + 1
# print(r.Text)
# print(i)
# print(round(i / 178.0 * 100,0))
# rounding off
progPercent = round(i / 178.0 * 100.0)
MyGlobals.x=progPercent
print(progPercent)
return progPercent
except:
print('Excel is not executed')
# sleep(1)
# self.event.wait()
def stop(self):
self.event.set()
在单片机.py在
^{pr2}$而且,测试.py在
class MyGlobals(object):
x = 0
所以,我可以从卓越结果.py进入单片机.py使用测试.py但完全不知道如何更新progressbar值。在
我试着用一个循环,但它挂起了图形用户界面。在
谢谢。在
使用Qthread:
相关问题 更多 >
编程相关推荐