summaryrefslogtreecommitdiffstats
path: root/examples3/semaphore.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples3/semaphore.py')
-rwxr-xr-xexamples3/semaphore.py66
1 files changed, 33 insertions, 33 deletions
diff --git a/examples3/semaphore.py b/examples3/semaphore.py
index ac8b231..68128d7 100755
--- a/examples3/semaphore.py
+++ b/examples3/semaphore.py
@@ -1,13 +1,13 @@
#!/usr/bin/env python
#
-# A port of the semaphore example from Qt.
+# A port of the semaphore example from TQt.
import sys
# Check if thread support was enabled.
try:
- from qt import QThread
+ from qt import TQThread
except:
print "Thread support not enabled"
sys.exit(1)
@@ -20,13 +20,13 @@ yellowSem = None
greenSem = None
-class YellowThread(QThread):
+class YellowThread(TQThread):
def __init__(self,o):
- QThread.__init__(self)
+ TQThread.__init__(self)
self.receiver = o
self.stopped = 0
- self.mutex = QMutex()
+ self.mutex = TQMutex()
def run(self):
global yellowSem, greenSem
@@ -34,9 +34,9 @@ class YellowThread(QThread):
for i in range(20):
yellowSem += 1
- event = QCustomEvent(12345)
- event.setData(QString("Yellow!"))
- QThread.postEvent(self.receiver,event)
+ event = TQCustomEvent(12345)
+ event.setData(TQString("Yellow!"))
+ TQThread.postEvent(self.receiver,event)
self.msleep(200);
greenSem -= 1
@@ -51,9 +51,9 @@ class YellowThread(QThread):
yellowSem += 1
- event = QCustomEvent(12346)
- event.setData(QString("Yellow!"))
- QThread.postEvent(self.receiver,event)
+ event = TQCustomEvent(12346)
+ event.setData(TQString("Yellow!"))
+ TQThread.postEvent(self.receiver,event)
greenSem -= 1
@@ -63,13 +63,13 @@ class YellowThread(QThread):
self.mutex.unlock()
-class GreenThread(QThread):
+class GreenThread(TQThread):
def __init__(self,o):
- QThread.__init__(self)
+ TQThread.__init__(self)
self.receiver = o
self.stopped = 0
- self.mutex = QMutex()
+ self.mutex = TQMutex()
def run(self):
global yellowSem, greenSem
@@ -77,9 +77,9 @@ class GreenThread(QThread):
for i in range(20):
greenSem += 1
- event = QCustomEvent(12345)
- event.setData(QString("Green!"))
- QThread.postEvent(self.receiver,event)
+ event = TQCustomEvent(12345)
+ event.setData(TQString("Green!"))
+ TQThread.postEvent(self.receiver,event)
self.msleep(200)
yellowSem -= 1
@@ -94,9 +94,9 @@ class GreenThread(QThread):
greenSem += 1
- event = QCustomEvent(12346)
- event.setData(QString("Green!"))
- QThread.postEvent(self.receiver,event)
+ event = TQCustomEvent(12346)
+ event.setData(TQString("Green!"))
+ TQThread.postEvent(self.receiver,event)
self.msleep(10)
yellowSem -= 1
@@ -107,24 +107,24 @@ class GreenThread(QThread):
self.mutex.unlock()
-class SemaphoreExample(QWidget):
+class SemaphoreExample(TQWidget):
def __init__(self):
- QWidget.__init__(self)
+ TQWidget.__init__(self)
self.yellowThread = YellowThread(self)
self.greenThread = GreenThread(self)
global yellowSem, greenSem
- yellowSem = QSemaphore(1)
- greenSem = QSemaphore(1)
+ yellowSem = TQSemaphore(1)
+ greenSem = TQSemaphore(1)
- self.button = QPushButton("&Ignition!",self)
+ self.button = TQPushButton("&Ignition!",self)
self.connect(self.button,SIGNAL("clicked()"),self.startExample)
- self.mlineedit = QMultiLineEdit(self)
- self.label = QLabel(self)
+ self.mlineedit = TQMultiLineEdit(self)
+ self.label = TQLabel(self)
- vbox = QVBoxLayout(self,5)
+ vbox = TQVBoxLayout(self,5)
vbox.addWidget(self.button)
vbox.addWidget(self.mlineedit)
vbox.addWidget(self.label)
@@ -151,7 +151,7 @@ class SemaphoreExample(QWidget):
def startExample(self):
if self.yellowThread.running() or self.greenThread.running():
- QMessageBox.information(self,"Sorry",
+ TQMessageBox.information(self,"Sorry",
"The threads have not completed yet, and must finish before "
"they can be started again.")
@@ -176,9 +176,9 @@ class SemaphoreExample(QWidget):
self.mlineedit.append(s)
if s.latin1() == "Green!":
- self.label.setEraseColor(Qt.green)
+ self.label.setEraseColor(TQt.green)
else:
- self.label.setEraseColor(Qt.yellow)
+ self.label.setEraseColor(TQt.yellow)
self.label.setText(s)
@@ -186,7 +186,7 @@ class SemaphoreExample(QWidget):
elif event.type() == 12346:
s = event.data()
- QMessageBox.information(self,s.latin1() + " - Finished",
+ TQMessageBox.information(self,s.latin1() + " - Finished",
"The thread creating the \"" + s.latin1() +
"\" events has finished.")
@@ -195,7 +195,7 @@ class SemaphoreExample(QWidget):
print "Unknown custom event type:", event.type()
-app = QApplication(sys.argv)
+app = TQApplication(sys.argv)
se = SemaphoreExample()
app.setMainWidget(se)
se.show()