Hi, I am trying to figure out how to implement a QThread class that will handle GUI event while keeping the GUI responsive.
I want to call thread's methods by their names and start() the thread from inside that method. My problem is with passing methods their arguments since start() wont take any argument. So I thought I could keep a global variable self.invoker which holds the name of currently called method and start the thread accordingly as follows: class Counter(QThread): def __init__(self, parent=None): super(Counter, self).__init__(parent) self.reset() def __del__(self): self.exiting = True self.wait() try: self.reset() # is not instantiated except TypeError: return def stop(self): self.__del__() def reset(self): self.exiting = False def countup(self, till): if not self.isRunning(): self.invoker = [self.countup, till] self.start() else: n = 0 while not self.exiting and n < till: n += 1 self.emit(SIGNAL("ticktock(int)", n)) def run(self): self.invoker[0](self.invoker[1], self.invoker[2]) But I cant always know the number of arguments the invoker has, can I? So can you please suggest me a better way of doing this please? Thanks in advance.
-- http://mail.python.org/mailman/listinfo/python-list