File: workerThread.py

package info (click to toggle)
releaseforge 1.1-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,088 kB
  • ctags: 1,239
  • sloc: python: 13,801; makefile: 68; sh: 32
file content (25 lines) | stat: -rw-r--r-- 642 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import sys
from qt import *
import time

class WorkerThread(QThread):
    def __init__(self, receiver, eventid, func, *args):
        QThread.__init__(self)
        self.receiver = receiver
        self.eventid = eventid
        self.func = func
        self.stopped = 0
        self.args = args


    def run(self):
        if not self.stopped:
            #time.sleep(5000)
            data = apply(self.func, self.args)
            if not self.stopped:
                event = QCustomEvent(self.eventid)
                event.setData(data)
                qApp.postEvent(self.receiver, event)

    def stop(self):
        self.stopped = 1