PDA

View Full Version : progress bar issues



shooogun
13th March 2008, 04:19
Hi all,

I'm trying to update a progress bar, but whenever I run setValue it crashes my program. The error I get looks like this:


X Error: BadRequest (invalid request code or no such operation) 1
Extension: 183 (Uknown extension)
Minor opcode: 0 (Unknown request)
Resource id: 0x36020ba

It doesn't happen on each iteration, only some initially, but then toward the end of the iteration, each setValue command fails, and then the program crashes.


X Error: BadRequest (invalid request code or no such operation) 1
Major opcode: 0 ()
Resource id: 0x36020ba

my code looks like this


x=0
while x < len(fileList):
# do stuff
self.progressBar.setValue(x)
x+=1

any advise?

jpn
13th March 2008, 07:32
Does this happen in the main GUI thread?

shooogun
13th March 2008, 23:32
I think so.

I create an instance of a class which inherits QThread, in the initializer of the mainwindow, and store that instance in a variable in the mainwindow class, so the pseudo code would be

class myThread(QThread):
def __init__(self):
QThread.__init__(self)

def run(self):
x=0
while x != progBarMax:
progressBar.setValue(x)
x+=1

class myInterface(QMainWindow, UIModule.My_UI):
def __init__(self, parent=None):
super(myInterface, self).__init__(parent)
self.setupUI(self)
self.interface = myThread()

@pyqtSignature("")
def on_button_clicked(self):
self.interface.start()

wysota
13th March 2008, 23:39
In that case you are accessing a GUI object (progressBar) from within a worker thread which is forbidden. You have to do that from within the GUI thread.

shooogun
14th March 2008, 05:57
Ok. Thanks for the help. It's working now