Example #1
0
class Stopper(QObject):
    start_timer = pyqtSignal()
    stop_timer = pyqtSignal()

    def __init__(self):
        super(Stopper, self).__init__()

        print "current thread 2 %r" % QThread.currentThread()
        self.timer = QTimer()
        self.thread_of_timer = self.timer.thread()
        print "stopper.timer thread: %r" % self.thread_of_timer
        self.timer.setInterval(1000)
        self.timer.timeout.connect(self.prnt_msg)
        self.start_timer.connect(self.start)
        self.stop_timer.connect(self.stop)

    def start(self):
        print "starting"
        self.timer.start()

    def stop(self):
        print "stopping"
        print QThread.currentThread()
        print self.thread()
        print self.timer.thread()
        print "Timer thread has changed: %s" % (self.thread_of_timer is self.timer.thread())
        self.timer.stop()

    def prnt_msg(self):
        print "timer running"