This question seems to have been asked many times in many different forms, but I could not find it with the appropriate code solution for me.
When I run the program, it shows
QObject :: installEventFilter: cannot filter events for objects in another thread.
Despite this, the code works initially, but after a while it bombes, and python gives an error saying that it stops 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 ):
busyBar = sqrl_QtTools.BusyBar( text = "Gathering Camera Data" )
busyBar.start()
busyBar.Kill()
class BusyBar(QThread):
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:
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
Jared source
share