Hi @all!
I'm new to to GUI programming and this is surely a simple newbie
question ;-)
I've created a small GUI with just one Button and a progessbar. If one
presses the Button a QStateMachine is created and started and performs
a
rather long running process.
Now, what I wanna do is to update a progessbar every time I'm entering
a new State. The Problem is that I'm running thru my StateMachine but
the progessbar is updated only _after_ the QStateMachine is finished!
So what I'm missing here?
Here is a snipplet of my code:
class MainWindow(QMainWindow, Ui_mainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.setupUi(self)
# Start the QStateMashine by pressing the Button
self.pushButton.clicked.connect(self.state_mashine)
def state_mashine(self):
self.progressBar_4.setValue(0)
machine = QStateMachine(self)
prepare = QState()
prepare.entered.connect(self.prepare_dut())
flash = QState()
flash.entered.connect(self.flash_dut())
config = QState()
config.entered.connect(self.config_dut())
finish = QFinalState()
finish.entered.connect(self.finish_dut())
prepare.addTransition(flash)
flash.addTransition(config)
config.addTransition(finish)
machine.addState(prepare)
machine.addState(flash)
machine.addState(config)
machine.addState(finish)
machine.setInitialState(prepare)
machine.start()
def prepare_dut(self):
self.progressBar_4.setValue(33)
print "State 1: Prepare DUT"
time.sleep(1)
def flash_dut(self):
self.progressBar_4.setValue(66)
print "State 2: Flash DUT"
time.sleep(1)
def config_dut(self):
self.progressBar_4.setValue(80)
print "State 3: Config DUT"
time.sleep(1)
def finish_dut(self):
self.progressBar_4.setValue(100)
print "State 4: DUT finished!"
time.sleep(1)
if __name__ == '__main__':
app = QApplication(sys.argv)
frame = MainWindow()
frame.show()
app.exec_()
_______________________________________________
PySide mailing list
[email protected]
http://lists.pyside.org/listinfo/pyside