Hi @all, I have a little controller QThread within my application. The controller should have a statemachine to do some jobs. My problem is that I'm not able to reuse the statemachine. This is my approach:
class Controller(QtCore.QThread): def __init__(self, parent=None): super(Controller, self).__init__(parent) self.machine = QtCore.QStateMachine() self._init_machine() def _init_machine(self): state_get_address = QtCore.QState() state_get_address.entered.connect(self._state_get_address()) state_get_command = QtCore.QState() state_get_command.entered.connect(self._state_get_command()) state_exec_command = QtCore.QState() state_exec_command.entered.connect(self._state_exec_command()) state_get_breakpoint = QtCore.QFinalState() state_get_breakpoint.entered.connect(self._state_get_breakpoint()) state_get_address.addTransition(state_get_command) state_get_command.addTransition(state_exec_command) state_exec_command.addTransition(state_get_breakpoint) self.machine = QtCore.QStateMachine() self.machine.addState(state_get_address) self.machine.addState(state_get_command) self.machine.addState(state_exec_command) self.machine.addState(state_get_breakpoint) self.machine.setInitialState(state_get_command) def run_machine(self): self.machine.start() def run(self): self.exec_() If I try to use it, the statemachine already runs for the first time when _init_machine() is called by the constructor (__init__()) ... what i'm missing here? Btw.: this is also the case if I manually call _init_machine() after starting the QThread's event loop ... c = Controller() c.start() # <- first execution on the state machine c.run_machine() c = Controller() c.start() c._init_machine() # <- first execution on the state machine c.run_machine() - Markus -- __________________________________________________________________ IMKO Micromodultechnik GmbH Markus Hubig System Administration & Development Im Stoeck 2 D-76275 Ettlingen / GERMANY HR: HRB 360936 Amtsgericht Mannheim President: Dipl.-Ing. (FH) Kurt Koehler Tel: 0049-(0)7243-5921-26 Fax: 0049-(0)7243-5921-40 e-mail: [email protected] internet: www.imko.de _________________________________________________________________
_______________________________________________ PySide mailing list [email protected] http://lists.pyside.org/listinfo/pyside
