This question seems to have been asked many times in many different forms but I haven't managed to find one with a -relevant to my code- solution.
When I run the program it shows
QObject::installEventFilter: Cannot filter events for objects in a different thread.
Despite this the code works initially but after a while it bombs and python gives an error saying its stopped working.
My code is as follows:
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