这个问题似乎已经以许多不同的形式被问过很多次,但我还没有找到一个与我的代码解决方案相关的问题。
当我运行程序时它显示
QObject::installEventFilter:无法过滤不同线程中对象的事件。
尽管如此,代码最初可以工作,但一段时间后它会爆炸,python 会给出一个错误,说它停止工作。
我的代码如下:
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from xml.etree import ElementTree as ET
import os , time
class LayoutCreator(QDialog):
def __init__(self , parent=None):
super(LayoutCreator, self).__init__(parent)
self.Cameras_Update()
def Cameras_Update( self ): # Get all shots with camera plots and add them to the cameras_tree
busyBar = sqrl_QtTools.BusyBar( text = "Gathering Camera Data" ) # Looping progress bar
busyBar.start()
# loop through folder structure storing data
busyBar.Kill() # Close looping progress bar
class BusyBar(QThread): # Looping progress bar
def __init__(self, text = "" ):
QThread.__init__(self)
self.text = text
self.stop = False
def run( self ):
self.proBar = QProgressBar()
self.proBar.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.SplashScreen )
self.proBar.setMinimum( 0 )
self.proBar.setMaximum( 100 )
self.proBar.setTextVisible( True )
self.proBar.setFormat( self.text )
self.proBar.setValue( 0 )
self.proBar.setFixedSize( 500 , 50 )
self.proBar.setAlignment(Qt.AlignCenter)
self.proBar.show()
while not self.stop: # keep looping while self is visible
# Loop sending mail
for i in range(100):
progress = self.proBar.value()
progress = progress + 1
self.proBar.setValue( progress )
time.sleep(0.05)
self.proBar.setValue( 0 )
self.proBar.hide()
def Kill(self):
self.stop = True